Page 1 of 1

Strange form submission error..

Posted: Wed Dec 07, 2005 2:46 pm
by Charles256

Code: Select all

if (isset($_REQUEST['yes']))
	{
		echo $_REQUEST['yes'];
		if ($_REQUEST['yes']=="yes")
		{
			$part=$_POST['part'];
			$desc=$_POST['desc'];
			echo $part;
			echo $desc;
			if (isset($desc) AND empty($part))
			{
				$sql="SELECT * FROM parts WHERE description LIKE '%".$desc."%'";
				$query=mysql_query($sql) or die(mysql_error());
				while ($test=mysql_fetch_object($query))
				{
					$display="<b>Go Kart Model: $test->gk_model </b><br />";
					$display .= "Part Number: $test->part_number<br />";
					$display .= "Image: <img src='images/parts/".$test->part_number.".jpg'";
					$display .= "Description: $test->description";
				}
			}
			else if (isset($part) AND empty($desc))
			{
				$sql="SELECT * FROM parts WHERE part_number LIKE '%".$part."%'";
				echo $sql;
				$query=mysql_query($sql) or die(mysql_error());
				while ($test=mysql_fetch_object($query))
				{
					$display="<b>Go Kart Model: $test->gk_model </b><br />";
					$display .= "Part Number: $test->part_number<br />";
					$display .= "Image: <img src='images/parts/".$test->part_number.".jpg'";
					$display .= "Description: $test->description";
				}
			}
			else if(empty($desc) AND empty($part))
			{
				$display="You must enter something.";
			}
			else {
				$display=" You must enter one or the other, not both. Sorry";
			}
		}
	}
	echo "Feel free to search by part number or part description. If your first
	search does not return any results try making your search terms a bit broader.<br />";
	
	echo "<form action='index.php?page=search&yes=yes' method='POST'>
			Part Number: <input type='text' name='part'></input><Br />
			Description: <input type='text' name='desc'></input><br />
			<input type='submit'></input>";
	echo "<br />";
	if (isset($display))
	{
		echo "$display";
	}
yes i realize it has no input sanitization but that's not the issue. when i submit the form none of the error check i put in get's echoed and for that matter the form doesn't display either.what the hell am i missing?

Posted: Wed Dec 07, 2005 2:58 pm
by shiznatix
does it go anywhere? have you tried doing echo 'here'; at different places to try to see what happens? also, you are still using $_REQUEST??? use $_GET instead.

Posted: Wed Dec 07, 2005 3:04 pm
by Charles256
yeah.i've tried echoing variables, tried echoing constants....nothing....not a damn thing..once i hit that form submission the page is gone....btw, the page is on index.php?page=search, i want the form to be on index.php?page=search&yes=yes, so it should work..yet..life hates me..

Posted: Wed Dec 07, 2005 9:08 pm
by shiznatix
hummm i dont see anything wrong but I have never seen the use of the constant "AND" like you are using it. try replacing that with && - I dont know if that will do anything but maybe?

Posted: Wed Dec 07, 2005 9:17 pm
by John Cartwright
is error_reporting == E_ALL? is display_errors == ON?

Posted: Wed Dec 07, 2005 10:47 pm
by Charles256
yep, display errors is on and error reporting is set to all and FYI in PHP you can use AND, part of the loosely typed jazz;) I do it if I am being to lazy to hit shift..and since I was in a hurry..no shift :-D grrr..going to eat this code and re-write it all..

Posted: Wed Dec 07, 2005 11:38 pm
by John Cartwright
I seriously don't know man :?
Check your apache error logs, maybe something is showing up there.

Posted: Thu Dec 08, 2005 9:41 am
by Charles256
nope.nothing in the error logs :-D last error was when I couldn't type in a page name, addkarts != addkart. doh. hehe. I'll let you know if I figure out something.

Posted: Thu Dec 08, 2005 9:44 am
by Charles256
here's one to boggle your noggin! check this out..absolutely amazing..if I type in index.php?page=search&yes=yes right off it shows everything. however if I hit that submit button the world goes to hades! the hell?!!!

Posted: Thu Dec 08, 2005 9:45 am
by Jenk
blank page?

Normally means a process is taking longer than the timeout setting in your php.ini. (such as an infinite loop)

Posted: Thu Dec 08, 2005 9:50 am
by Charles256
allow me to rephrase..i'm using includes to construct my page layout... it loads up the header, navigation,fotter, it's just the content doesn't load.lemme try commenting out stuff...

edit: this still didn't fire off..don't think it's an infinite loop...

Code: Select all

if (isset($_REQUEST['yes']))
	{
		if ($_REQUEST['yes']=="yes")
		{
			$part=$_POST['part'];
			$desc=$_POST['desc'];
			/*if (isset($desc) AND empty($part))
			{
				$sql="SELECT * FROM parts WHERE description LIKE '%".$desc."%'";
				$query=mysql_query($sql) or die(mysql_error());
				while ($test=mysql_fetch_object($query))
				{
					$display="<b>Go Kart Model: $test->gk_model </b><br />";
					$display .= "Part Number: $test->part_number<br />";
					$display .= "Image: <img src='images/parts/".$test->part_number.".jpg'";
					$display .= "Description: $test->description";
				}
			}
			else if (isset($part) AND empty($desc))
			{
				$sql="SELECT * FROM parts WHERE part_number LIKE '%".$part."%'";
				echo $sql;
				$query=mysql_query($sql) or die(mysql_error());
				while ($test=mysql_fetch_object($query))
				{
					$display="<b>Go Kart Model: $test->gk_model </b><br />";
					$display .= "Part Number: $test->part_number<br />";
					$display .= "Image: <img src='images/parts/".$test->part_number.".jpg'";
					$display .= "Description: $test->description";
				}
			}
			*/
			if(empty($desc) AND empty($part))
			{
				$display="You must enter something.";
			}
			else {
				$display=" You must enter one or the other, not both. Sorry";
			}
		}
	}

Posted: Thu Dec 08, 2005 9:57 am
by Charles256
I FIGURED IT OUT! hehe. On a previous page request finally shot me in the foot... i used $_REQUEST['part'] for a get variable ande then here I had a post part on the same page due to the nature of the include system so when i had both page=search and the part variable set the system didn't know which page to include and we end up with a blank page. be careful kiddies when doing includes.

Posted: Thu Dec 08, 2005 11:01 am
by John Cartwright
No, be careful when using $_REQUEST. You should know exactly where your data is coming from, and if there are several possibilities, it is ideal to encapsulate the possibilities into a function to sort the mess out.