topical media & game development
basic-php-12-user-login.php / php
<?php
session_start();
include "conn.inc.php";
if (isset(query = "SELECT username, password FROM user_info " .
"WHERE username = '" . _POST['password'] . "'))";
query)
or die(mysql_error());
if (mysql_num_rows(_SESSION['user_logged'] = _SESSION['user_password'] = _POST['redirect'] . "");
echo "You are being redirected to your original page request!<br>";
echo "(If your browser doesn't support this, " .
"<a href=\"" . _POST['redirect']; ?>">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br><br>
<input type="submit" name="submit" value="Login">
</form>
</p>
</body>
</html>
<?php
}
} else {
if (isset(redirect = redirect = <index.php>;
}
?>
<html>
<head>
<title>Beginning PHP5, Apache and MySQL</title>
</head>
<body>
<p>
Login below by supplying your username/password...<br>
Or <a href=<register.php>>click here</a> to register.<br><br>
<form action="user_login.php" method="post">
<input type="hidden" name="redirect"
value="<?php echo
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.