sam06 Posted June 5, 2007 Share Posted June 5, 2007 Hi, Does anyone know where I can get a simple login mysql script that has 3 rows - username and password, and another that it automatically is set at 20 and the user cannot edit? I would than be able to use the variables $username and $credit on any page. If someone has a few minutes spare time I would be very greatful if someone could help me out. Kind Regards, Sam Hale. Quote Link to comment https://forums.phpfreaks.com/topic/54322-a-php-login-script/ Share on other sites More sharing options...
burtybob Posted June 5, 2007 Share Posted June 5, 2007 This is a basic login script it might need a minor edit to make it work for you in the way you want but that should mean just basic php knowledge. LOGIN FORM <html> <body><form action="welcome.php" method="post"><br> Username: <input type="text" name="username" /><br> Password: <input type="password" name="password" /><br> <input type="submit" /> </form></body> </html> LOGIN CHECK AGAINST DATABASE <?php include('config.php'); mysql_connect($database,$username,$password); @mysql_select_db(contacts) or die( "Unable to select database"); $query="SELECT * FROM login"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $user=mysql_result($result,$i,"Username"); $pass=mysql_result($result,$i,"Password"); $location=mysql_result($result,$i,"Location"); $user2 = $_POST['username']; $pass2 = $_POST['password']; if ($user == $user2 && $pass == $pass2) { echo "<a href=$location>Your Profile</a>"; } elseif ($user != $user2 && $pass != $pass2) { echo "incorrect username and password"; }else { echo "wah me not pingu"; } ?> LOGIN CONFIG FILE <?php //config.php $database = "your database"; $username = "database username"; $password = "database password"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/54322-a-php-login-script/#findComment-268640 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.