Jump to content

need help with $_GET and IF()


jeger003

Recommended Posts

hello everyone,

im having some issues using $_GET to echo some stuff.

 

 

here is my code.......below is my issue

echo "<br>";
echo "<table>
    <tr>
    	<td colspan='2' align='center'>Search All Visits<td>
    <tr>
	    <form action=/index.php?a=search&b=result method=get>
		<td>Enter:</td>
		<td><input type=text name=c value='' /></td>
	</tr>
	<td><input type=submit name=submit value=Submit /></td>
	</table>";
echo "<br>";









//list all visits
echo "<br><br><a href='/visitors/index.php?d=all&e=visits>List All</a><br><br>";


//-----------can delete below
$get_a = $_GET['a'];
$get_b = $_GET['b'];
$get_c = $_GET['c'];
$get_d = $_GET['d'];
$get_e = $_GET['e'];
if($get_a = search && $get_b = result)
{
echo "search 1st if<br><br>";
}	
if($get_d == all && $get_e = visits)
{
echo "list all 2nd if <br><br>";		
}

if( empty($get_a) && empty($get_b) && empty($get_c))
{
echo "500 limit 3rd if";
}

 

 

basically i want it to echo specific code when values of $_GET a,b,c,d,e are equal to something specific to url or the form.....but when it runs query it would display more than one result

 

 

like if i clicked the link (see code) List All it would echo "list all 2nd if" but it would also echo "search 1st if" and "500 limit 3rd if"........the same with if i enter a value in the form it would display 1st if and 3rd if

 

how can i get it to only echo specific to a,b,c,d, and e

 

i would appreciate any help

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/145213-need-help-with-_get-and-if/
Share on other sites

i got it working

 

 

but i want to retrieve the name 'c' in the form....thats what im using to match with the database.....the form is basically a search....when i use 'post' i can $_GET a and b but if i use 'get' in the form it shows 'c' but then it wont run query.

 

echo "<br>";
echo "<table>
    <tr>
    	<td colspan='2' align='center'>Search All Visits<td>
    <tr>
	    <form action='/visitors/index.php?a=1&b=2' method='post'>
		<td>Enter:</td>
		<td><input type='text' name='c' value='' /></td>
	</tr>
	<td><input type=submit name=submit value=Submit /></td>
	</table>";
echo "<br>";









//list all visits
echo "<br><br><a href='/visitors/index.php?a=3&b=4>List All</a><br><br>";


//-----------can delete below
$get_a = $_GET['a'];
$get_b = $_GET['b'];
$get_c = $_GET['c'];
if(isset($get_a) && isset($get_b))
{
if($get_a == 1 && $get_b == 2 )
{
	echo "search 1st if <br><br>";
	echo $get_c;
}
if($get_a == 3  && $get_b == 4 )
{
	echo "list all 2nd if <br><br>";		
}
}
else
{
echo "500 limit 3rd if";
}

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.