View Full Version : !isset

01-12-2006, 02:38 PM
I am trying to find a way to tell if


is set or not, i am using

if(!isset($submit)) { echo "submit is set";}

but it displays everytime whether the submit button is clicked or not. any ideas on how to do what I want to do?


01-12-2006, 02:42 PM
if(!isset($submit)) { // if $submit is NOT set
echo "submit is NOT set";

I think you have mixed up your code


if(isset($submit)) { // if $submit is set
echo "submit is set";

Also note that PHP is case sensitive so Submit is different to submit.
This can cause problems with forms if you use a submit button named submit

01-12-2006, 02:50 PM
I am actually trying to check to see if $submit has already been entered,
I have the


after the initial

if(!isset($submit)) { // if $submit is NOT set
echo "submit is NOT set";

otherwise on my next page of search results, they don't come up until after you hit the submit button again.

thanks for the heads up, but I do everything in lower case so as not to get things confused.

01-12-2006, 02:59 PM
If you load a page then submit will not be set and you will see the message.
If you have submitted the page then submit will be set.

I haven't seen your code but I still think you have it the wrong way around.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>


if(isset($submit)){ echo "submit is set"; }
<form name="form1" method="post" action="">
<input type="submit" name="submit" value="Submit">