PDA

View Full Version : Help With A Login Code!


JoJo2000
08-12-2002, 06:48 PM
:confused: I'll take anyones help. I'm only 12, but i have my own website i'm making. I'm really confused with how to make a login. So that they sign up and are added i nto the server. I also don't know how to get a server.
Would this code work:
<html>
<head>
</head>

<body bgcolor=#ffffff>
<?
if(isset($UserName) && isset($password) && isset($hometown) && isset($age) && isset($email) && isset($start_city)) {
$dbhandle = @mysql_connect("localhost", "dbusername", "dbpassword") or die("Unable to connect to database at this time");
mysql_select_db("databasenamegoeshere", $dbhandle);
$query = "INSERT INTO pregame VALUES ('$UserName','$password','$hometown','$age','$email','$start_city')";
if (mysql_query($query)){
echo "<p>$UserName was added to the database</p>";
}
}
?>

<h1>regester</h1>
<form method="post" action="<?=$PHP_SELF?>">
User Name: <input type="text" name="UserName"><br>
Password: <input type=text name="password"><br>
<input type="submit">
</form>


</body>
</html>
Thanks if you help me!:thumbsup:

mordred
08-12-2002, 10:14 PM
Originally posted by JoJo2000
I'm really confused with how to make a login. So that they sign up and are added i nto the server. I also don't know how to get a server.


Perhaps you should clarify what you mean with "server". Usually you should check if your provider enables you to use PHP and (for this script) MySQL as a database.

As to your code, yes that could work, if circumstances were right. But it's not what I would call a login functionality, it has more of a "register" script. Specifically, it adds the POST data of the form as a new user into a MySQL table.