Solved

How to determine if a link is clicked or not staying on the same page in PHP?

Posted on 2011-09-30
3
146 Views
Last Modified: 2012-05-12
Hi,

I have a link on the page, say X, saying "Connect" clicking on which user is redirected to another page, say Y. If everything goes fine on page Y, the user is redirected to page X but instead of link, there is a text saying "Account Connected". But if something goes wrong on page Y, then I need to catch the error and display it on page X and let the link still remain active. How do I do this is in PHP? Since I am not an expert in PHP, I dont know how to do this and I need quick answers as I m stuck with my project.

Thanks in advance
0
Comment
Question by:ishani_v
  • 3
3 Comments
 
LVL 13

Accepted Solution

by:
Andrew Derse earned 500 total points
ID: 36891476
You would send variables back and forth through the URL using PHP.

On page X you will need code at the top to catch if there is anything from Page Y.

That code would look like this:
 
<?php

if (isset($_GET['test']))
{
$x = $_GET['test'];
} else {
$x = no;
}

Open in new window


Then you need to pass the test variable from Y to X like this:
 
<a href="page-x.php?test='$results';>Submit</a>

Open in new window


The: test = $result is set to have $result being the message you want to send back.  It can be whatever you want, but it needs to be something logical.

Back to the X page we finish the logical check to display the X or Account Connected bit.
 
if ($test = 'OK') {
$buttonText = 'Account Connected";
} else {
$buttonText = "X";
}

Open in new window


That's the gist of it.  Please let me know if you need more assistance with this.
0
 
LVL 13

Expert Comment

by:Andrew Derse
ID: 36891482
Wow, sorry, I didn't close the strings properly...

Third code, line 2 needs to be:
 
$buttonText = "Account Connected";

Open in new window


0
 
LVL 13

Expert Comment

by:Andrew Derse
ID: 36891490
And one more thing...make the Third code: line 1

if ($test == 'OK') {

It needs to have 2 equal signs, not one...

(Still too early in the morning for me...sorry about that)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article we have discussed about the OS X EI Capitan and how to fix Wi-Fi issue in OS X El Capitan. We have explained how to delete system level preferences and create a new Wi-Fi location to resolve Wi-Fi issue.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question