Well I've been searching the internet the whole day for some PHP/MySQL signup and login scripts. There is no luck whatsoever.
Can someone point me in the direction (or make me one ^_^) of a simple signup and login script?
OR...I did find this tutorial on how to make one and it did work. The only problem is is that no matter what account you login with, it goes to the same page (getin.php). If anyone could tweak it so it redirects to a certain page depending on the user, it would be very appreciated! (Codes below)
(Example: someone logins with username: hello --> redirects to hello.php)
login.php: (login page)
Code: Select all
<form action="getin.php" method="post">
Username: <input type="text" name="username" size="10"><p>
Password: <input type="password" name="password" size="10"><p>
<input type="submit" value="Login" name="submit">
</form>Code: Select all
<?
$conn = mysql_connect("localhost","****","****");
$db = mysql_select_db("****");
$username = $_POST["username"];
$password = $_POST["password"];
$result = MYSQL_QUERY("SELECT * from users WHERE username='$username'and password='$password'")
or die ("Name and password not found or not matched");
$worked = mysql_fetch_array($result);
$username = $worked[username];
$password = $worked[password];
$email = $worked[email];
?>
<?
if($worked)
echo "Welcome $username! Please wait. Contacting database...";
?>Code: Select all
<?
$conn = mysql_connect("localhost","****","****");
$db = mysql_select_db("****");
$username = $_POST["username"];
$password = $_POST["password"];
$email = $_POST["email"];
$result= MYSQL_QUERY("INSERT INTO users (id, username, password, email)".
"VALUES ('NULL', '$username', '$password', '$email')");
echo "Your name and password have been submitted into our database.";
?>I know the redirection thing isn't the most secure, but my site uses IFrames and I have a no right-click script on every page so it's impossible to hack....right?
P.P.S. ---------------------
Yes, the actual database names and passwords are intact.
Thank you!