Page 1 of 1

[SOLVED] Post or Get method not being recieved

Posted: Sat Aug 20, 2005 10:13 pm
by ianhull
Hi Guys,

I am having another little issue here with get or post.

I have created a form like this

Code: Select all

<form name="form1" id="form1" method="post" action="admin">
                <div align="right">
	<input name="usrname" type="text" id="usrname" />
                <input name="pwd" type="password" id="pwd" />
	<input name="Submit" type="submit" class="style4" value="Submit" />
                 </div>
                </form>
But when I type my username and password I get undefined in my php processor which uses this sql


Code: Select all

$sql = "SELECT companyname, firstname, lastname, email, password, ulevel, username, jobtitle, website FROM users WHERE username='$_POST[usrname]' AND password='$_POST[pwd]' ORDER BY companyname";
I have tried switching to get but it still does not work.
Yet if I type in my browser http://svr1/myadminpage.php?usrname=myu ... mypassword it works great.

Can anyone tell me where my problem is?

Thanks

Posted: Sat Aug 20, 2005 10:23 pm
by feyd
post the actual error, and form please.

Posted: Sat Aug 20, 2005 10:27 pm
by ianhull
Notice: Undefined index: usrname in C:\Xeneo\vr\admin\index.php on line 4

Notice: Undefined index: pwd in C:\Xeneo\vr\admin\index.php on line 4

Code: Select all

<?php 
include ("connect.php"); 

$sql = "SELECT companyname, firstname, lastname, email, password, ulevel, username, jobtitle, website FROM users WHERE username='$_POST[usrname]' AND password='$_POST[pwd]' ORDER BY companyname"; 

$r = mysql_query($sql);
if(!$r) {
$err=mysql_error();
print $err;
exit();
}
if(mysql_affected_rows()==0){
print include_once("failedlogin.php");
exit();
}
else{

}
echo "\n";

while ($line = mysql_fetch_array($r))    
      {
      extract($line);
      }
echo "\n";
$usrlevel = "$ulevel";
$adminlevel = "Yes"; 
{ 
  if ($usrlevel == $adminlevel){ 
      echo include("admincontent.php"); 
  } else { 
      echo include("usercontent.php"); 
  } 
}  
?>

Code: Select all

<form name="form1" id="form1" method="post" action="admin">
                  <div align="right">
				    <input name="usrname" type="text" id="usrname" />
				    <input name="pwd" type="password" id="pwd" />
				    <input name="Submit" type="submit" class="style4" value="Submit" />
                  </div>
                </form>

Posted: Sat Aug 20, 2005 10:35 pm
by feyd
it kind of feels like you're hitting a redirection with the submission, which is tossing the data... can you confirm that?

Posted: Sat Aug 20, 2005 10:42 pm
by ianhull
Thanks for you help.

It was because in my html form I was using just the admin folder to redirect to and not the page inside it.

it works great now.

Thanks.

Code: Select all

<form name="form1" id="form1" method="post" action="admin/index.php"> // this line
                  <div align="right"> 
                <input name="usrname" type="text" id="usrname" /> 
                <input name="pwd" type="password" id="pwd" /> 
                <input name="Submit" type="submit" class="style4" value="Submit" /> 
                  </div> 
                </form>