Solved

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

Posted on 2011-09-30
3
143 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:
NUKIT 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:NUKIT
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:NUKIT
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…

760 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