Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-09-30
3
Medium Priority
?
155 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 2000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
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…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

604 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