Jump to content

switch with $_GET please help cheers. <<need more help cheers


redarrow

Recommended Posts

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>

<?php

if($_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

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>

<?php

if($_GET['2']==2){
echo "hi";
exit;
}

?>

<?php }?>

[/code]
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>

<?php


if($_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]
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.
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>

<?php


switch($_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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.