Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request Method Error 1

Status
Not open for further replies.

Coogan

Programmer
Jun 21, 2004
38
GB
Hello all,

I am having a problem with the below script and im not sure why.

The error message that I am getting is:

Notice: Undefined variable: request_method in C:\Program Files\Apache Group\Apache2\htdocs\fns\login.php on line 49

However this code is working fine on a hosted site and not on an internal machine with the same install of Apache, SQL and PHP. I have always used the $request_method option of checking if a form is being posted and never had any problems until now.

Any suggestions??

Thanks

Coogan

Code:
<form name="form1" method="post" action="">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table width="277" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="118"><span class="style1">Username:</span></td>
      <td width="159"><input name="username" type="text" id="username" size="20" maxlength="12"></td>
    </tr>
    <tr>
      <td class="style1">Password:</td>
      <td><input name="password" type="password" id="password" size="20" maxlength="8"></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
        <input name="login" type="submit" id="login" value="login">
      </div></td>
    </tr>
  </table>
  <?

    # processed when form is submitted back onto itself
    if ($request_method=="post") {

        # setup SQL statement
		$login_id = $username;
		$login_pass = $password;
		if ($login_id== '') {$login_id="blank";}
		if ($login_pass== '') {$login_pass="blank";}
        $SQL = " SELECT * FROM fns_admin";
        $SQL = $SQL . " WHERE username = '$login_id' ";
		
		# execute SQL statement
	    $retid = mysql_db_query($db, $SQL, $cid);

    	# check for errors
	    if (!$retid) { echo( mysql_error()); }
			else {	$row = mysql_fetch_array($retid);
					$user_id = $row["confirm_id"];
					$user_pass = $row["password"];
					$user_user = $row["username"];
					if ($user_user== $login_id) {if ($user_pass== $login_pass) {echo("<SCRIPT 

LANGUAGE=javascript>document.location= \"/admin.php?userid=$user_id\"</script>");}
													else { echo("<p 

class=\"style1\" align=\"center\">Invalid Username or Password</p>"); }
													}
							else {echo("<p class=\"style1\" align=\"center\">Invalid Username or 

Password</p>"); }
					#echo("$user_id");
				}
		}
	?>
</form>
 
newer versions of php will complain if you haven't set a variable prior to it being called.

if you used for example:

if(isset($_POST['id'])) {

.....

everything should be fine.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top