PDA

View Full Version : authencate email


wando
11-03-2002, 09:06 PM
well, ive had this problem for months. i want on my website a registration script that for you to enter my site, you need to register with a valid email address, that is recorded on a mysql database. can anyone help. i would like to do it myself rather than pay anyone else to, but i just need a script. thanks very much. There is one problem tho, my server does not support ASP. it is Apache, and its a real pain in the arse me trying to configure anything.
thanks again
chris

Nightfire
11-03-2002, 09:56 PM
Get the user to enter their username and email address into a form. Create a random password and email the password to that address. If the user has a fake email address, they can't get in.

I've got it running like that on my site. Also have a script to delete the details out of the db if the user hasn't logged in within 30 days (assuming they gave a false email address).

I take it you have php?

(written on the fly, so may be a few errors)

if(!isset($submit)){
//form not submitted
echo '<form action="'.$PHP_SELF.'" method="post">
<input type="text" name="username"> Username<br>
<input type="text" name="email"> Email<br>
<input type="submit" name="submit" value="Register">';

}else{

//your db info here
include("includes/dbinfo.php");

//connect to db
@mysql_connect($dbhost,$dbuname,$dbpass) OR die("Could not connect to the database please make sure the sign in info is correct");
@mysql_select_db($dbname) OR die("That database does not appear to exist or you do not have permissions to manipulate it");

//create random password
srand((double)microtime()*1000000);
$ID = substr(md5(rand(0,32000)), 0, 10);
$r = rand(0,1);
if ($r == "0") {
$ID;
} else {
$ID = strtoupper($ID);
}
$password = $ID;

//insert info into db
$sql = "insert into users (username, email, password) values ('$username', '$email', '$password')";
$result = mysql_query($sql);

//mail info and password
$subject = "Your password";
$msg = "Password: $password";
$from = "From: You@email.com";

mail ($email,$subject,$msg,$from);

echo "Your password has now been emailed to $email";
}