By the way, I know there are some security flaws (I'm fixing them later).
<?php
//connectingto database
$connect = mysql_connect(localhost, mattsmin_user, roots);
if(!$connect) {
die("Could not donnect: " . mysql_error());
}
//choose databse to use
$database = mysql_select_db(mattsmin_data);
if(!$database) {
die("Could not connect to database: " . mysql_error());
}
//aquire usernames from the form login.php
$username = $_POST['username'];
$password = $_POST['password'];
//check if user supplied a username to log in with
if($username == FALSE) {
echo "You forgot a username! ";
}
//check if user supplied password to log in with
if($password == FALSE) {
echo "You forgot a password! ";
}
$query = mysql_query("SELECT username, password FROM users WHERE username = '$username' and password = '$password' ");
$result = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($result);
if($count < 0) {
header('index.php');
}
else {
echo "Username or password was typed wrong. Go <a href='login.php'>back</a>?";
}
?>

New Topic/Question
Reply




MultiQuote





|