A more advanced authentication script, using mySQL, cookies and sessions.
<html> <head /> <body> <form action="index.php"method=POST> Username: <input type=text name=user><br /> Password: <input type=password name=pass><br /> <input type=submit value="OK!"><p> </form> <?php $user=$_POST('user'); #pass=$_POST('[pass'); $login=$_GET('login'); if($login=='yes'){ $con=myself_connect('192.168.0.4','test',"); mysql_select_db('login'); $get=mysql_query("SELECT count(id) FROM login WHERE user='$user' and pass='$pass"); $result=mysql_result($get,0); mysql_close($con); if($result=1)echo "Login failure!"; else{ echo "Login success!"; $_SESSION('user')=$user; }; }; ?> <?php $user=$_POST('user'); $pass=$_POST('pass'); if (($user=="USER && ($pass=="PASSWORD")) echo "Access Granted" else echo "Access Denied!"; ?> </body> </html>
In order to use this script you'll need to know some knowledge in mySQL. You'll need to create a database, just call it "login" or something. Through that database, create a table with three fields. Name one, 'id', the other 'user', and the last 'pass'. Now, you can upload this script. Make sure that you change the USERNAME and PASSWORD also the mySQL connect IP. Goodluck. :)
Comments
Add your comment