MyBB Hacks

Full Version: PHP form errors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,
I'm trying to add a form in my php script but can't seem to get it working correctly. It's basically a form that allows the user to search for people in an sql database.

Here is the part that seems to be going wrong:

PHP Code:
echo '<form name="search" method="post" action="'.$targetpage.'"><td><input type="text" name="find" size="50" maxLength="30" /></td>';
	echo '<td><Select NAME="field"><Option VALUE="name">Player Name</option><option VALUE="steamid">Steam ID</option><option VALUE="ip">IP Address</option></select><input type="hidden" name="searching" value="yes" /><input type="submit" name="search" value="Search" /></form></td></tr>';
	if ($searching == "yes")
 	{
		echo "Search Successful!";
		if ($find == "")
 		{
 			echo "<tr class=\"trow1\"><td>You didn't give me anything to search for</td></tr></table>"; 
 exit; 
 		}


For some reason it won't even get passed that first if statement. I can't get it to echo search successful. Any help would be greatly appreciated.

Well it would fail if $searching isn't equal to 'yes'.
Your next step would be to find out what the hell $searching is, means and what value it is at that point in the code, and whether it's what you expect it to be.
I thought that was referring to this part of the form:

PHP Code:
<input type="hidden" name="searching" value="yes" />


Would the if statement be able to capture that?

No, HTML and PHP don't mix.  HTML is rendered on the client machine, PHP is executed on the server machine.
Maybe you mean $_REQUEST['searching'] although that may not work as you're way too vague.
Ahh thanks so much ZiNgA, that worked using that Biggrin.
I was using this tutorial http://php.about.com/od/phpwithmysql/ss/...http://php.about.com/od/phpwithmysql/ss/php_se for this. Specificaly pages 2 and 3 for that tutorial. Unless I missed something, that tutorial must be incorrect?
The web is riddled with shit PHP tutorials. (considering that like 95% of "PHP programmers" can't program)
I would presume that they may be using register globals which has actually been removed from PHP entirely these days.
Reference URL's