Jump to content

A PHP Login Script?


sam06

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/54322-a-php-login-script/
Share on other sites

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";
?>

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/54322-a-php-login-script/#findComment-268640
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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