469,950 Members | 1,813 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

i am trying to setup a link in my page that will change my page

I am working on a page with a right column that I want to use for
navigation. In this right column I am using the below code to set a
value for the link. I am using the variable $test right now.
I want to click on the link and when the value is set to a certain
value, say 1, I want the script to run and load a page based on a
switch case. This way I can use different links for navigation that
will load different forms and areas of my application. So here is the
code for the link line.

printf("<a href=\"%s?test=%s\">%s</a><br>\n", $_SERVER['PHP_SELF'],"1",
"Click Here");

I then want a switch statement to the effect

switch($test) {
case "1" :
Load form1
case "2" :
Load form2
case "3" :
Load form3;
}

To test out my idea I wrote this little test script to see if I could
get the response I wanted and it didn't work. I wanted to click on the
link and then get the value of test to echo back at me on the page.
Here is that code. I called the file testlink.php

<?php

printf("<a href=\"%s?test=%s\">%s</a><br>\n", $_SERVER['PHP_SELF'],"1",
"Click Here");

if (isset($test)){
echo "$test</br>\n";
}
?>
I get the right info in my url in my browser,

http://localhost/testlink.php?test=1

But I don't get the echo on the screen. Can anyone help?

May 17 '06 #1
2 1569
rich wrote:
I am working on a page with a right column that I want to use for
navigation. In this right column I am using the below code to set a
value for the link. I am using the variable $test right now.
I want to click on the link and when the value is set to a certain
value, say 1, I want the script to run and load a page based on a
switch case. This way I can use different links for navigation that
will load different forms and areas of my application. So here is the
code for the link line.

printf("<a href=\"%s?test=%s\">%s</a><br>\n", $_SERVER['PHP_SELF'],"1",
"Click Here");

I then want a switch statement to the effect

switch($test) {
case "1" :
Load form1
case "2" :
Load form2
case "3" :
Load form3;
}

To test out my idea I wrote this little test script to see if I could
get the response I wanted and it didn't work. I wanted to click on the
link and then get the value of test to echo back at me on the page.
Here is that code. I called the file testlink.php

<?php

printf("<a href=\"%s?test=%s\">%s</a><br>\n", $_SERVER['PHP_SELF'],"1",
"Click Here");

if (isset($test)){
echo "$test</br>\n";
}
?>
I get the right info in my url in my browser,

http://localhost/testlink.php?test=1

But I don't get the echo on the screen. Can anyone help?

$test = isset($_GET['test']) ? $_GET['test'] : null;

Add before you first use $test.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 17 '06 #2
Jerry thanks alot. I have been programming PHP for a month now and I
still forget little things. Here is the final code which worked of
course.

<?php
error_reporting(E_ALL ^ E_NOTICE);
$test =$_REQUEST['test'];

printf("<a href=\"%s?test=%s\">%s</a><br>\n", $_SERVER['PHP_SELF'],"1",
"Click Here");

if (isset($test)){
echo "$test</br>\n";
}
?>

May 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by JJ | last post: by
12 posts views Thread by Ron Weldy | last post: by
25 posts views Thread by Neo Geshel | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.