PHP form errors
mdb Offline
Junior Member
**
Posts: 27
Joined: May 2012
Post: #1
PHP form errors
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:
1
2
3
4
5
6
7
8
9
10
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.

07-29-2012 10:31 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: PHP form errors
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.

My Blog
07-29-2012 02:51 PM
Find all posts by this user Quote this message in a reply
mdb Offline
Junior Member
**
Posts: 27
Joined: May 2012
Post: #3
RE: PHP form errors
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?

07-29-2012 06:11 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: PHP form errors
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.

My Blog
07-29-2012 09:05 PM
Find all posts by this user Quote this message in a reply
mdb Offline
Junior Member
**
Posts: 27
Joined: May 2012
Post: #5
RE: PHP form errors
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?
07-30-2012 02:58 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #6
RE: PHP form errors
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.

My Blog
07-30-2012 07:50 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: