HTTP 403 error upon submitting form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kitsch
    New Member
    • Nov 2008
    • 2

    HTTP 403 error upon submitting form

    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:

    Code:
    <form name="search" method="post" action="$PHP_SELF?">
    Seach for: <input type="text" name="find" /> in 
    <Select NAME="field">
    <Option VALUE="fname">First Name</option>
    <Option VALUE="lname">Last Name</option>
    <Option VALUE="info">Profile</option>
    </Select>
    <input type="hidden" name="searching" value="yes" />
    <input type="submit" name="search" value="Search" />
    </form>
    
    <?
    if ($searching =="yes") 
    { 
    echo "<h2>Results</h2><p>"; 
    
     
    if ($find == "") 
    { 
    echo "<p>You forgot to enter a search term"; 
    exit; 
    } 
    
    
    mysql_connect("localhost", "root", "m1ch3ll3") or die(mysql_error()); 
    mysql_select_db("sample") or die(mysql_error()); 
    
    
    $find = strtoupper($find); 
    $find = strip_tags($find); 
    $find = trim ($find); 
    
    
    $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"); 
    
    //And we display the results 
    while($result = mysql_fetch_array( $data )) 
    { 
    echo $result['fname']; 
    echo " "; 
    echo $result['lname']; 
    echo "<br>"; 
    echo $result['info']; 
    echo "<br>"; 
    echo "<br>"; 
    } 
    ?>
    hoping you could help me. thanks.
    Last edited by Markus; Nov 15 '08, 10:32 PM. Reason: added # tags
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    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?

    Comment

    • kitsch
      New Member
      • Nov 2008
      • 2

      #3
      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.

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

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

        Change this line:
        [code=html]<form name="search" method="post" action="$PHP_SE LF?">[/code]

        to this:
        [code=html]<form name="search" method="post" action="<?php echo htmlentities($_ SERVER['PHP_SELF']); ?>">[/code]

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Looks like you're using register_global s. Please note that this is feature is completely discared for PHP 6.

          Markus.

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            You also might find this article to be of interest:

            Comment

            Working...