Solved

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

Posted on 2011-09-30
3
148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
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…

728 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