Creating a real user database / Log-in.
IF YOU CHOOSE TO REGISTER, PLEASE DO NOT USE YOUR REAL PASSWORD OR ANYTHING OF THAT SORT, because I DO have access to the information. Thanks.
Well, I've taken to learning PHP and mySQL, and this is what I've come up with so far : http://67.142.29.254:8000/ . It is a basic login form that compares userinformation to a mySQL database, and also I created a registration form that places data in the mySQL database. If any of you are interested, as I find it very interesting and I have only done so little, I could probably write a full tutorial on how I did it for pure newbs, but for now I'll just post source
.
This is the code for the login :
it's very simple and i'm sure there are better ways to do this, but basically what it does is currently it takes the username you entered (ignoring the pass at first), and then finds it in the table. It then compares the password you entered with the actual password in the database.
here is the actual registration code which puts the data in the database :
anyways, feedback I guess.
Well, I've taken to learning PHP and mySQL, and this is what I've come up with so far : http://67.142.29.254:8000/ . It is a basic login form that compares userinformation to a mySQL database, and also I created a registration form that places data in the mySQL database. If any of you are interested, as I find it very interesting and I have only done so little, I could probably write a full tutorial on how I did it for pure newbs, but for now I'll just post source
.This is the code for the login :
Code:
<?php
@$user=$_POST["Username"];
@$password=$_POST["Password"];
if (($user == NULL) || ($password == NULL))
{
echo ( " No account information entered, please try again. ");
exit();
}
$connect=mysql_connect("localhost", "artificialwings", "*******");
if (!$connect) {
echo( "unable to connect to mysql database..." );
exit();
}
else
{
echo( "Connected succesfully.<br>" );
}
echo( "Checking access...<br>" );
echo( "Selecting database...<P>" );
mysql_select_db("artificialwings", $connect);
$work="SELECT user, password, email, number FROM users WHERE user='" . $user . "'";
$results=mysql_query($work);
$data=mysql_fetch_array($results);
if ($data["password"] == $password){
echo ( " You have successfully logged in . . . <P>" .
"<B>Account Information</b><p>" .
"Username : " . $data["user"] .
"<p>Password : " . $data["password"] .
"<p>Email Address : " . $data["email"] .
"<p>User Number : " . $data["number"] );
}
else
{
echo ( " Invalid password . . . " );
}
?> here is the actual registration code which puts the data in the database :
Code:
<?php
$user=$_POST["Username"];
$password=$_POST["Password"];
$password2=$_POST["Password2"];
$email=$_POST["Email"];
$userm="'" . $user . "'";
$passwordm="'" . $password . "'";
$emailm="'" . $email . "'";
if (($password != $password2) || ($password2 == NULL) || ($password == NULL) || ($email == NULL))
{
echo "Passwords did not match, please retry.";
exit();
}
$connect=mysql_connect("localhost", "artificialwings", "*******");
if (!$connect){
echo "couldn't register..";
}
mysql_select_db("artificialwings", $connect);
echo ("success.. registering..");
//area below simply finds what member number the new account will be
$findamountofusers="select MAX(number) from users;";
$dowork=mysql_query($findamountofusers);
$number=mysql_fetch_array($dowork);
$getnumber=$number["MAX(number)"];
$actual=$getnumber+1;
$actualm="'" . $actual . "'";
$work="insert into users (user, password, email, number) VALUES (". $userm . "," . $passwordm ."," . $emailm . "," . $actualm .");";
$register=mysql_query($work);
?> Last edited by ArtificialWings : 05-13-2005 at 09:44 PM.









Linear Mode


