I hv make an html page on which there r 2 fields of username n pw n a login button.For Authentication code I make another file named "check.php".Kindly guide me that hw can I give the refernce of the form objects in this file as I need the values of username n pw in order to check.

mysql_select_db("alauddin", $con);
$name=form1.txtusername;
$password=form1.txtpw;
$result = mysql_query("SELECT username,pw FROM login");
while($row = mysql_fetch_array($result))
  {
 if($name=$row['username'] && $password=$row['pw'])
 echo "You are logged in";
 else
 echo "Enter again";
  }

Its giving error on the following lines as its the form1 in the html file:

$name=form1.txtusername;
$password=form1.txtpw;

I include the file "check.php" in the html file.
Reply soon..Regards,

Hello.

If you have form like this:

<form action="check.php" method="post">
<input type="text" name="username" value="">
<input type="text" name="password" value="">
<input type="submit" name="submit">
</form>

...you can access form values like this:

$_POST['username'] // username
$_POST['password'] // password

- Mitko Kostov

Thankx for ur guidance.Is there any function in php which works as Break function in c++.As I want to terminate the execution at a particular point.

Regards,

Hello.

If you have form like this:

<form action="check.php" method="post">
<input type="text" name="username" value="">
<input type="text" name="password" value="">
<input type="submit" name="submit">
</form>

...you can access form values like this:

$_POST['username'] // username
$_POST['password'] // password

- Mitko Kostov

Is there any error in the code I posted b4 as its not giving the correct results.Is its correct?

while($row = mysql_fetch_array($result))
  {
 if($name=$row['username'] && $password=$row['pw'])
 echo "You are logged in";
 else
 echo "Enter again";
  }

Hello.

If you have form like this:

<form action="check.php" method="post">
<input type="text" name="username" value="">
<input type="text" name="password" value="">
<input type="submit" name="submit">
</form>

...you can access form values like this:

$_POST['username'] // username
$_POST['password'] // password

- Mitko Kostov

Can u plzz check the code I posted b4 n let me know if thers any errors as its not giving the correct results:

while($row = mysql_fetch_array($result))
  {
 if($name=$row['username'] && $password=$row['pw'])
 echo "You are logged in";
 else
 echo "Enter again";
  }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.