|
RutiX ::and for the gay who said that Password function doesnt exist, he should see the "PHP and MySQL 3dbuzz" video or this book "Wrox - Beginning PHP, Apache, MySQL Web Development - 2004 - (By Laxxuss).pdf" to see that there is a function password() and also md5 function.
I sincerely hope you meant "guy", if no, you'll see help from me no more.
Look, I do not claim that I know everything about php and mysql. There is no manual for function password() on the official php.net site, so I presume that there is no such function. Predefined by default.
You should read them (not just them), but you should try "PHP for dummies".
$query="SELECT username,password FROM 'table' WHERE username='".$_POST['username']."' and password = md5('".$_POST['password']."') ";
so this is not working, and you want user authentication script? why didnt you used search on this forum?
you have 100% working script on [Link mogu videti samo ulogovani korisnici] (written by me, who else?)
<?php
session_start();
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname, $connect) or die(mysql_error());
if (isset($_POST['logmein'])) {
$usr_pass = md5($_POST['password']);
$usr_user = $_POST['username'];
$respass2 = mysql_query("SELECT password FROM ime_tabele WHERE username='$usr_user'");
$row = mysql_fetch_array($respass2);
if ($usr_pass == $row{'password'}) {
$_SESSION['username'] = $usr_user;
$_SESSION['password'] = $usr_pass;
echo "<script>location.href='index.php';</script>";
die();
}
else {
echo "<script>location.href='login.php';</script>";
die();
}
}
$username=$_SESSION['username'];
$password=$_SESSION['password'];
if ($username != "" and $password != "") {
$respass = mysql_query("SELECT password FROM ime_tabele WHERE username='$username'");
$row = mysql_fetch_array($respass);
if ($password != $row{'password'}) {
$_SESSION['username'] = "";
$_SESSION['password'] = "";
echo "<script>location.href='login.php';</script>";
die();
}
}
else {
echo "<form action='login.php' method='post'><input type='text' name='username' value='username' onfocus=\"document.forms[0].elements[0].value=''\"><br><br><input type='password' name='password' value='password' onfocus=\"document.forms[0].elements[1].value=''\"><br><br><input type='submit' name='logmein' value=\"Pristupi\" ></form>";
die();
}
?>
|