Hoi,
heb het volgende script:
Maar kryg dus wel een email met de link waar je op moet klikken om registratie te bevestigen, maar als ik dan op de link klik, kryg ik elke x de boodschap:
"De URL is ongeldig"!!
Een voorbeeld van zo links is:
http://localhost/www/hsleiden/project2_2007/php/login2/activate.php?id=ydazgn
Greetings
heb het volgende script:
Code:
<?php
include("connection.php");
session_start();
if(isset($_POST['submit']))
{
$voornaam = addslashes(trim($_POST['voornaam']));
$tussenvoegsel = addslashes(trim($_POST['tussenvoegsel']));
$achternaam = addslashes(trim($_POST['achternaam']));
$geboortedatum = addslashes(trim($_POST['geboortedatum']));
$postcode = addslashes(trim($_POST['postcode']));
$land = addslashes(trim($_POST['land']));
$username = addslashes(trim($_POST['username']));
$email = addslashes(trim($_POST['email']));
$pass = addslashes(trim($_POST['password']));
$conf = addslashes(trim($_POST['confirm']));
$ip = $_SERVER['REMOTE_ADDR'];
$date = date("d, m y");
if ( $_POST['password'] == $_POST['confirm'] )
{}else{
echo '<script>alert("Your passwords were not the same, please enter the same password in each field.");</script>';
echo '<script>history.back(1);</script>';
exit;
}
$password = md5($pass);
if ((((( empty($voornaam) ) || ( empty($achternaam) ) || ( empty($username) ) || ( empty($email) ) || ( empty($password) )))))
{
echo '<script>alert("One or more fields was left empty, please try again.");</script>';
echo '<script>history.back(1);</script>';
exit;
}
if((!strstr($email , "@")) || (!strstr($email , ".")))
{
echo '<script>alert("You entered an invalid email address. Please try again.");</script>';
echo '<script>history.back(1);</script>';
exit;
}
$q = mysql_query("SELECT * FROM gebruikers WHERE username = '$username'") or die(mysql_error());
if(mysql_num_rows($q) > 0)
{
echo '<script>alert("The username you entered is already in use, please try again.");</script>';
echo '<script>history.back(1);</script>';
exit;
}
$name = $voornaam . ' ' . $achternaam;
//$actkey = mt_rand(1, 500).'f78dj899dd';
//$act = sha1($actkey);
//******************BEGIN*************************************************************
// Hier wordt de unieke sleutel gecreeerd voor de mail!!
//
function randomstring($len)
{
srand(date("s"));
while($i<$len)
{
$str.=chr((rand()%26)+97);
$i++;
}
$str=$str.substr(uniqid (""),0,22);
return $str;
}
// Now generate the 6-digit code
$actkey = randomstring(6); // 6 for a 6-digit code
$actkey = substr("$actkey", 0, 6); // added to fix bug.
//***************EINDE*************************************************************************
$query = mysql_query("INSERT INTO gebruikers (username, password, voornaam,achternaam,tussenvoegsel,geboortedatum,
postcode,land,geslacht, email,ip,actkey,active)
VALUES ('$username','$password','$voornaam','$achternaam','$tussenvoegsel','$geboortedatum'
,'$postcode','$land','$geslacht','$email','$ip','$actkey','$active')") or die(mysql_error());
$send = mail($email , "Registration Confirmation" , "Thank you for registering by Coinnovation!.\n\n
Your username and password is below, along with details on how to activate your account.\n\nUser:
".$username."\nPass: ".$pass."\n\nClick the link below to activate your account:
\nhttp://localhost/www/hsleiden/project2_2007/php/login2/activate.php?id=".$actkey." \n\n
Please do not reply, this is an automated mailer.\n\nThanks", "FROM: [email]nengelen@orange.nl[/email]");
if(($query)&&($send))
{
echo ' <html>
<head>
<title>Success</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="success">
<p>Thank you for registering, you will recieve an email
soon with your login details and your activation link so that you can activate your account.</p>
<p><a href="login.php">Click here</a> to login once you have activated.</p>
</div>
</body>
</html>
';
} else {
echo '
<html>
<head>
<title>Error</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="error">
<p>We are sorry, there appears to be a problem with our script at the moment.</p>
<p>Your data was not lost. Username: '.$username.' | Password: '.$pass.' | Email: '.$email.' | Full name: '.$name.'</p>
<p>Please try again later.</p>
</div>
</body>
</html>
';
}
} else {
mysql_close();
}
?>
<html>
<head>
<title>Register</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<div id="head">Registratie pagina</div>
<br>
<div id="main">
<p>Je kan je hier geristreren! </p>
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50%">Voornaam </td>
<td width="50%"><input name="voornaam" type="text" id="voornaam"></td>
</tr>
<tr>
<td width="50%">Tussenvoegsel </td>
<td width="50%"><input name="tussenvoegsel" type="text" id="tussenvoegsel"></td>
</tr>
<tr>
<td>Achternaam</td>
<td><input name="achternaam" type="text" id="achternaam"></td>
</tr>
<tr>
<td width="50%">Geboortedatum </td>
<td width="50%"><input name="geboortedatum" type="text" id="geboortedaum"></td>
</tr>
<tr>
<td width="50%">Land </td>
<td width="50%"><input name="land" type="text" id="land"></td>
</tr>
<tr>
<td width="50%">Postcode </td>
<td width="50%"><input name="postcode" type="text" id="postcode"></td>
</tr>
<tr>
<td width="50%">Geslacht </td>
<td width="50%"><input name="geslacht" type="radio" id="man" value="man" checked="checked"></td>
<tr><td></td><td><input name="geslacht" type="radio" id="vrouw" value="vrouw" checked="checked"></td></tr>
</tr>
<tr>
<td>Email Address </td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td>gebruikers naam</td>
<td><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td>Password(herhaal) </td>
<td><input name="confirm" type="password" id="confirm"></td>
</tr>
<tr>
<td>Register</td>
<td><input name="submit" type="submit" class="textBox" value="Submit"></td>
</tr>
</table>
</form>
deze website. </div>
</div>
</body>
</html>
Hier dan nog het script "activatie.php" :
<?php
include("connection.php");
session_start();
// Eerst een basiscontrole uitvoeren op de URL
if(!isset($_GET['sleutel']) || !isset($_GET['username'])) {
echo 'De URL is ongeldig.';
} else {
// Om een account te activeren moeten we gewoon de activatie-
// gegevens uit de tabel gooien:
mysql_query("DELETE FROM gebruikers WHERE
gebruiker_id = ".intval($_GET['gebruiker'])." AND
sleutel = '".mysql_real_escape_string($_GET['sleutel'])."'");
// mysql_affected_rows()
// of in dit geval dus verwijderd. Zo weten we ook gelijk of de gegevens wel juist waren!
if(mysql_affected_rows() == 0) {
echo 'De account bestaat niet of was reeds geactiveerd.';
} else {
// Er is een rij aangetast, dus is het gelukt :)
echo 'De activatie is gelukt. Je kan nu <a href="login.php">Inloggen</a>';
}
}
?>
Maar kryg dus wel een email met de link waar je op moet klikken om registratie te bevestigen, maar als ik dan op de link klik, kryg ik elke x de boodschap:
"De URL is ongeldig"!!
Een voorbeeld van zo links is:
http://localhost/www/hsleiden/project2_2007/php/login2/activate.php?id=ydazgn
Greetings
Laatst bewerkt: