Strange form submission error..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Strange form submission error..

Post 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?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post 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..
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

is error_reporting == E_ALL? is display_errors == ON?
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post 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..
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I seriously don't know man :?
Check your apache error logs, maybe something is showing up there.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post 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.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post 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?!!!
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

blank page?

Normally means a process is taking longer than the timeout setting in your php.ini. (such as an infinite loop)
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post 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";
			}
		}
	}
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
Post Reply