Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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