Solved

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

Posted on 2011-09-30
3
144 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There is a security feature on iOS devices that is nearly impenetrable when it has been activated.  This article will provide some possible solutions as well as necessary steps to take to ensure you do not end up with a locked device.
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.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now