Jump to content

[SOLVED] User Log On Form


Vitamin

Recommended Posts

I have a forum on one page and I'm passing though 2 variables.  Username and Password.

 

<?php
$link = mysql_connect('localhost','root','password')
or die("Failed Logon");
mysql_select_db("users");
$username = $_POST['username'];
$password = $_POST['password'];
if($username=="" || $password=="")
{
die("Please do not leave the username / password field blank!");
}
$result = mysql_query("SELECT * FROM users WHERE
username=$username AND password=$password");
$number = mysql_num_rows($result);
if($number==0)
{
die("Your login details are not right. Please click the back button
and correct them.");
}
echo $password ;
echo $username ;
?>

 

I know every thing works up to the point where it reaches the select statement then something is going wrong.  I have all the correct information in the database and I've tried different users, but none are working.

 

Any help would be appreciated.  I'm new to php, but have done simular things with CF and Access.

Link to comment
https://forums.phpfreaks.com/topic/127494-solved-user-log-on-form/
Share on other sites

<?php
$link = mysql_connect('localhost','root','password')
or die("Failed Logon");
mysql_select_db("users");
$username = $_POST['username'];
$password = $_POST['password'];
if($username=="" || $password=="")
{
die("Please do not leave the username / password field blank!");
}
$result = mysql_query("SELECT * FROM users WHERE
username=". $username ." AND password=". $password");
$number = mysql_num_rows($result);
if($number==0)
{
die("Your login details are not right. Please click the back button
and correct them.");
}
echo $password ;
echo $username ;
?>

That should do it

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.