Connecting Tech Pros Worldwide Forums | Help | Site Map

HTTP 403 error upon submitting form

Newbie
 
Join Date: Nov 2008
Posts: 2
#1: Nov 15 '08
Good day.
I'm basically new to PHP programming, and I'm getting a grasp. I've been googling anywhere possible but I can't seem to have codes working for me. I have a code and when the form is submitted, it gives off an 'HTTP 403' error. Here's the code:

Expand|Select|Wrap|Line Numbers
  1. <form name="search" method="post" action="$PHP_SELF?">
  2. Seach for: <input type="text" name="find" /> in 
  3. <Select NAME="field">
  4. <Option VALUE="fname">First Name</option>
  5. <Option VALUE="lname">Last Name</option>
  6. <Option VALUE="info">Profile</option>
  7. </Select>
  8. <input type="hidden" name="searching" value="yes" />
  9. <input type="submit" name="search" value="Search" />
  10. </form>
  11.  
  12. <?
  13. if ($searching =="yes") 
  14. echo "<h2>Results</h2><p>"; 
  15.  
  16.  
  17. if ($find == "") 
  18. echo "<p>You forgot to enter a search term"; 
  19. exit; 
  20.  
  21.  
  22. mysql_connect("localhost", "root", "m1ch3ll3") or die(mysql_error()); 
  23. mysql_select_db("sample") or die(mysql_error()); 
  24.  
  25.  
  26. $find = strtoupper($find); 
  27. $find = strip_tags($find); 
  28. $find = trim ($find); 
  29.  
  30.  
  31. $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"); 
  32.  
  33. //And we display the results 
  34. while($result = mysql_fetch_array( $data )) 
  35. echo $result['fname']; 
  36. echo " "; 
  37. echo $result['lname']; 
  38. echo "<br>"; 
  39. echo $result['info']; 
  40. echo "<br>"; 
  41. echo "<br>"; 
  42. ?>
hoping you could help me. thanks.

pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Nov 16 '08

re: HTTP 403 error upon submitting form


Heya, kitsch.

A 403 usually means that you don't have correct file permissions set up for the file.

Are you running an Apache or IIS server?
Newbie
 
Join Date: Nov 2008
Posts: 2
#3: Nov 16 '08

re: HTTP 403 error upon submitting form


Quote:

Originally Posted by pbmods

Heya, kitsch.

A 403 usually means that you don't have correct file permissions set up for the file.

Are you running an Apache or IIS server?



Hello.
I'm running Apache 2.2.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#4: Nov 16 '08

re: HTTP 403 error upon submitting form


Hm. I gave your code another look-over. Let's try one thing first.

Change this line:
Expand|Select|Wrap|Line Numbers
  1. <form name="search" method="post" action="$PHP_SELF?">
to this:
Expand|Select|Wrap|Line Numbers
  1. <form name="search" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#5: Nov 16 '08

re: HTTP 403 error upon submitting form


Looks like you're using register_globals. Please note that this is feature is completely discared for PHP 6.

Markus.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#6: Nov 16 '08

re: HTTP 403 error upon submitting form


You also might find this article to be of interest:
http://php.net/register_globals
Reply