redarrow Posted December 6, 2006 Share Posted December 6, 2006 Hi there all advance thank you.i am trying to get the link with a value example1=1 to be used via the $_GET statement but it dosent work is there a reason for it and it it's not possable how do i use a method like the switch statement to get the link to show whats on the same page when pressed cheers[code]<table border='4' bordercolor='black'><td><a href="login_result.php?1=1">Change Home Page</a></td><td><a href="login_result.php?2=2">Change Register Page</a></td><td><a href="login_result.php?3=3">Change about me Page</a></td><td><a href="login_result.php?4=4">Delete Unwanted blogs</a></td></table></div> <?phpif($_GET['$2']=='2'){echo "hi";exit;}?>[/code] Link to comment https://forums.phpfreaks.com/topic/29625-switch-with-_get-please-help-cheers/ Share on other sites More sharing options...
keeB Posted December 6, 2006 Share Posted December 6, 2006 [code]<?phpif($_GET['2'] ==2 ){echo "hi";}?>[/code]It amazes me you have close to 3,300 posts on this site :X Link to comment https://forums.phpfreaks.com/topic/29625-switch-with-_get-please-help-cheers/#findComment-135931 Share on other sites More sharing options...
redarrow Posted December 6, 2006 Author Share Posted December 6, 2006 i tried that before posting and in fact that correction you made does not effect the way the get function works for some reason the code poulates the reirect and never uses the get statement please help cheers. [code]<?php session_start();if( empty($name)||empty($password)){header("location: login.php");} $db=mysql_connect("localhost","xxx","xxxx");mysql_select_db("mat_website",$db); $query="select * from admin where name='$name' and password='$password'";$result=mysql_query($query);if( mysql_num_rows($result)==1){ ?><html><head><title>Dj Phc</title><body bgcolor="#ff333" vlink="blue" link="blue" alink="blue"><?php $date_now=date("d-m-y");$time_now=date("h:i:s");$ip=$_SERVER['REMOTE_ADDR'];?><table align="center"><td><font color="yellow">Date([<?php echo $date_now;?>])</font></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><font color="yellow">Time([<?php echo $time_now;?>])</font></td><td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><font color="yellow">Ip Logged([<?php echo $ip?>])</font></td></table><?php include("header.php");?><p></p><div align="center"><b><h1>Admin Area Only</h1><table border='4' bordercolor='black'><td><a href="login_result.php?1=1">Change Home Page</a></td><td><a href="login_result.php?2=2">Change Register Page</a></td><td><a href="login_result.php?3=3">Change about me Page</a></td><td><a href="login_result.php?4=4">Delete Unwanted blogs</a></td></table></div> <?phpif($_GET['2']==2){echo "hi";exit;}?><?php }?>[/code] Link to comment https://forums.phpfreaks.com/topic/29625-switch-with-_get-please-help-cheers/#findComment-135937 Share on other sites More sharing options...
redarrow Posted December 6, 2006 Author Share Posted December 6, 2006 solved forgot to add the session information at the top of the page cheers all.[code]$name=$_SESSION['name']=$name;$password=$_SESSION['password']=$password;[/code] Link to comment https://forums.phpfreaks.com/topic/29625-switch-with-_get-please-help-cheers/#findComment-135949 Share on other sites More sharing options...
redarrow Posted December 6, 2006 Author Share Posted December 6, 2006 please help i can not get the get statement to work all i get is the link correct and a blank page cheers.[code]<?php session_start();$db=mysql_connect("localhost","xxxx","xxxx");mysql_select_db("mat_website",$db); $query="select * from admin where name='$name' and password='$password'";$result=mysql_query($query);if( mysql_num_rows($result)==1){?><html><head><title>Dj Phc</title><body bgcolor="#ff333" vlink="blue" link="blue" alink="blue"><?php $date_now=date("d-m-y");$time_now=date("h:i:s");$ip=$_SERVER['REMOTE_ADDR'];?><table align="center"><td><font color="yellow">Date([<?php echo $date_now;?>])</font></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><font color="yellow">Time([<?php echo $time_now;?>])</font></td><td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><font color="yellow">Ip Logged([<?php echo $ip?>])</font></td></table><?php include("header.php");?><p></p><div align="center"><b><h1>Admin Area Only</h1><table border='4' bordercolor='black'><td><a href="login_result.php?cmd=link_one">Change Home Page</a></td><td><a href="login_result.php?cmd=link_two">Change Register Page</a></td><td><a href="login_result.php?cmd=link_three">Change about me Page</a></td><td><a href="login_result.php?cmd=link_four">Delete Unwanted blogs</a></td></table></div> <?phpif($_GET['cmd']==link_one){echo "link 1";}elseif($_GET['cmd']==link_two){echo "link 2";}elseif($_GET['cmd']==link_three){echo "link 3";}elseif($_GET['cmd']==link_four){echo "link 4";}?><?php }?>[/code] Link to comment https://forums.phpfreaks.com/topic/29625-switch-with-_get-please-help-cheers/#findComment-136002 Share on other sites More sharing options...
The Little Guy Posted December 6, 2006 Share Posted December 6, 2006 [code]<?phpif($_GET['cmd']=="link_one"){echo "link 1";}elseif($_GET['cmd']=="link_two"){echo "link 2";}elseif($_GET['cmd']=="link_three"){echo "link 3";}elseif($_GET['cmd']=="link_four"){echo "link 4";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/29625-switch-with-_get-please-help-cheers/#findComment-136006 Share on other sites More sharing options...
redarrow Posted December 6, 2006 Author Share Posted December 6, 2006 i think i got all my wires mixed up here as i have used all the get code as possable i need you all to no that the code is on all the same page so maybe it's only a switch that can help pleae help cheers.so the quistion is how do you use a switch on the same page as a link cheers. Link to comment https://forums.phpfreaks.com/topic/29625-switch-with-_get-please-help-cheers/#findComment-136009 Share on other sites More sharing options...
The Little Guy Posted December 6, 2006 Share Posted December 6, 2006 [code]<?phpswitch($_GET['cmd']){case "link_one":$text = 'Link 1';break;case "link_two":$text = 'Link 2';break;case "link_three":$text = 'Link 3';break;case "link_four":$text = 'Link 4';break;}echo $text;?>[/code] Link to comment https://forums.phpfreaks.com/topic/29625-switch-with-_get-please-help-cheers/#findComment-136011 Share on other sites More sharing options...
redarrow Posted December 6, 2006 Author Share Posted December 6, 2006 this should work on thesame page but it's blank thank u four ur help[code]<table border='4' bordercolor='black'><td><a href="login_result.php?cmd=link_one">Change Home Page</a></td><td><a href="login_result.php?cmd=link_two">Change Register Page</a></td><td><a href="login_result.php?cmd=link_three">Change about me Page</a></td><td><a href="login_result.php?cmd=link_four">Delete Unwanted blogs</a></td></table></div> <?phpswitch($_GET['cmd']){case "link_one":$text = 'Link 1';break;case "link_two":$text = 'Link 2';break;case "link_three":$text = 'Link 3';break;case "link_four":$text = 'Link 4';break;}echo $text; ?>[/code] Link to comment https://forums.phpfreaks.com/topic/29625-switch-with-_get-please-help-cheers/#findComment-136013 Share on other sites More sharing options...
JasonLewis Posted December 6, 2006 Share Posted December 6, 2006 is there a ?cmd=link_one in the link. if you want a default add this below the last blank:[code=php:0]default:$text = 'Default Text';[/code]note with the default you dont have to use case or end it with a break; Link to comment https://forums.phpfreaks.com/topic/29625-switch-with-_get-please-help-cheers/#findComment-136016 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.