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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.