oke, nu heb ik dit voor register.php:
******************************************************************************************
maar dan krijg ik by register.php deze foutmelding:
********************************************************************************************
"Warning: mail() [function.mail]: SMTP server response: 503 in C:\xampp\htdocs\www\hsleiden\project2_2007\php\login2\register.php on line 143" en dat is by deze regel: $ok = mail($mail, $titel, $boodschap, "FROM: <nengelen@orange.nl>");
*********************************************************************************************
PHP:
<?php
include("connection.php"); // maakt contact met de databse
session_start();// zodat alle sessie variabelen beschikbaar zijn
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 link
//
/*
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.
*/
function generateHash ( $length )
{
$chars = 'abcdefghijklmnopqrstuvwxyz23456789';
$numChars = strlen ( $chars );
$string = '';
for ( $i = 0; $i < $length; $i++ )
{
$string .= substr ( $chars, rand ( 1, $numChars ) - 1, 1 );
}
return sha1($string);
}
//***************EINDE*************************************************************************
//***************************************************BEGIN*********************************************************************************************
//Stuurt de gebruiker een mail met daarin de gegevens en een link om zich te activeren!!
/*
$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]");
*/
$code = generateHash(10);
// De code genereren.
$insertact = "INSERT INTO activation (id_user, sha1) VALUES (".$id.", '".$code."')";
// De net-geregistreerde user met z'n code in de tabel 'activation' zetten.
$actresult = mysql_query($insertact);
$titel = "Activatiecode";
$boodschap =
"Beste blabla,
Uw activatielink.
http://localhost/www/hsleiden/project2_2007/php/login2/activate.php?id=$id&activation=$code&type=login_activation
";
$ok = mail($mail, $titel, $boodschap, "FROM: <nengelen@orange.nl>");
//****************************************************EINDE********************************************************************************************
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();
}
?>
<!-- *************************************REGISTRATIE FORMULIER*****************************************************************************-->
<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>
[./PHP]
***************************************************************************************************
en dit voor activate.php:
[.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>';
}
}
*/
$id = $_GET['id'];
$code = $_GET['activation'];
$type = $_GET['type'];
if($type = 'login_activation'){
$query = "SELECT * FROM activation WHERE sha1 = '".$code."' AND id_user = '".$id."'";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
if($numrows == 1){
$update = "UPDATE gebruikers SET activation = 1 WHERE id_user = '".$id."'";
$resultupdate = mysql_query($update);
$delete = "DELETE FROM activation WHERE id_user = '".$id."'";
$resultdelete = mysql_query($delete);
echo $l_activationMessage;
}else{
echo $l_deactivationMessage;
}
}else{
}
?>
maar dan krijg ik by register.php deze foutmelding:
********************************************************************************************
"Warning: mail() [function.mail]: SMTP server response: 503 in C:\xampp\htdocs\www\hsleiden\project2_2007\php\login2\register.php on line 143" en dat is by deze regel: $ok = mail($mail, $titel, $boodschap, "FROM: <nengelen@orange.nl>");
*********************************************************************************************
Laatst bewerkt door een moderator: