i am new to using mysql with php and need help getting a user auth to work with an e-commerce website.
can anyone take a look at it and give me feedback on what else i would need to do to get the login process to work. i need a user registration and login forms.
thanks
here is my code below:
LOGIN.HTML
<form action="login.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>
LOGIN.PHP
<?
$db_name = "dbname";
$table_name = "ecom";
$link_id = mysql_connect("localhost", "dbuser", "dbpass")
or die("Couldn't connect.");
$db = mysql_select_db($db_name, $link_id)
or die("Couldn't select database.");
mysql_query ("SELECT * FROM $table_name WHERE auser == '$auser' AND apass == '$apass'");
echo "$select<br>";
$host ="localhost";
$username="dbuser";
$password="dbpass";
$database="db";
mysql_connect($host,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
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>");
}
?>