i am creating an e-commerce website, the users need to sign up for an account and also sign into their account with their username and password before they move forward to the checkout phase.
i am trying to create an user auth so that the users can sign in and out when they want to buy an item from the store
what would i need to do and what code would i need to get this user auth to work?
i would like to work with sessions for the user auth.
here's the html and php code that i have for the site so far. i need help creating the user auth for the site?
thanks
LOGIN.HTML
<center>
<font size="+1">Please Login to your Account</font>
<br>
<form action="login3.php" name="form1" method="post" onsubmit="return validate(this)">
<input type="hidden" name="select" value=" ">
Username
<input type="text" name="auser" size="20" maxlength="20"><br>
Password
<input type="text" name="apass" size="20" maxlength="20"><br>
<input type="submit" name="submit" value="SUBMIT" width="20" height="20">
</form>
if you have not registered,<br> please register here<br>
<a href="account.html">Register</a>
</center>
LOGIN.PHP
<?
$host ="localhost";
$username="user";
$password="pass";
$database="database";
$table_name = "tablename";
$connection = mysql_connect( $host, $username, $password ) or die( "Connection Error" );
mysql_select_db($database);
$user = $POST['auser'];
$pass = $POST['apass'];
$result = mysql_query("SELECT * FROM $table_name WHERE auser == '$user' AND apass == '$pass'");
if ($auser == "$auser" AND $apass == "$apass")
{
echo "<br><br><center><font size='+2'>Welcome $auser <br>Click here to logon <br><br>";
echo "
<form action='login.html' method='post'>
<input type='hidden' name='select2' value='$auser'>
<a href='login.html'>login</a>
</form>
";
}
elseif ($auser <> "$auser" AND $apass <> "$apass")
{
echo "You are rejected, information has not been accepted as valid.<br><a href='login.html'>Login</a>";
}
else
{
echo ("<font size='+2'><strong>YOU GOT REJECTED</strong></font>, <BR> YOU MUST LOGIN FIRST <BR>BEFORE YOU MOVE ON<BR><a
href='login.html'>LOGIN</a><br>");
}
?>