<?php
$submit = $_POST['submit'];
$id = $_GET['id'];
$firstname = strip_tags($_POST['firstname']);
$lastname = strip_tags($_POST['lastname']);
$email = addslashes(strip_tags($_POST['email']));
$username = addslashes(strip_tags($_POST['username']));
$password = addslashes(strip_tags($_POST['password']));
$verifypassword = strip_tags($_POST['verifypassword']);
$date = date("Y-m-d");
if($submit){
if($firstname&&$lastname&&$email&&$username&&$password&&$verifypassword&&$date){
if($password == $verifypassword){
if(strlen($firstname)>25||strlen($lastname)>25||strlen($username)>25){
echo "<b>Maximum limit</b> for the First, Last and username's are 25 characters";
}else{
if(strlen($password)>25||strlen($password)<6){
echo "Password must be <b>between</b> 6 and 25 characters!";
}else{
$password = md5($password);
$verifypassword = md5($verifypassword);
$random = rand(23456789,98765432);
$sql = "INSERT INTO users VALUES('','$firstname','$lastname','$email','$random','0','$username','$password','$date')";
$res = mysql_query($sql) or die(mysql_error());
$lastid = mysql_insert_id();
$to = $_POST['email'];
$subject = "Activate your account!";
$body = "
Hello $firstname $lastname,\n\n
You need to activate your account with the link below...
http://localhost/projects/p_web/index.php?p=activate&id=$lastid&code=$random\n\n
Thanks!
";
mail($to, $subject, $body);
echo "Success! Check your email to activate your account!";
}
}
}
}else{
echo "Passwords <b>Do Not Match</b>!";
}
}else{
echo "Please fill in <b>all</b> fields!";
}
?>
<form action="index.php?p=reg" method="POST">
<table>
<h1>Register</h1>
<tr><td>First Name: </td><td><input type="text" name="firstname" value="<?php echo $firstname; ?>" /></td></tr>
<tr><td>Last Name: </td><td><input type="text" name="lastname" value="<?php echo $lastname; ?>" /></td></tr>
<tr><td>Email: </td><td><input type="text" name="email" value="<?php echo $email; ?>" /></td></tr>
<tr><td>Username: </td><td><input type="text" name="username" value="<?php echo $username; ?>" /></td></tr>
<tr><td>Password: </td><td><input type="password" name="password" /></td></tr>
<tr><td>Verify Password: </td><td><input type="password" name="verifypassword" /></td></tr>
<tr><td><input type="submit" name="submit" value="Register" /></tr></td>
</table>
</form>
But this is the bit I want to look at in particular
$to = $_POST['email'];
$subject = "Activate your account!";
$body = "
Hello $firstname $lastname,\n\n
You need to activate your account with the link below...
http://localhost/projects/p_web/index.php?p=activate&id=$lastid&code=$random\n\n
Thanks!
";
$headers = "From: noskiw@googlemail.com";
ini_set("SMTP", "smtp.googlemail.com");
mail($to, $subject, $body, $headers);
echo "Success! Check your email to activate your account!";
And I get this error
Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. l23sm27686503wbb.8 in C:\xampp\htdocs\projects\p_web\include\reg.php on line 53
And my php.ini settings are
[mail function]
; For Win32 only.
SMTP = smtp.googlemail.com
smtp_port = 465
; For Win32 only.
;sendmail_from = noskiw@googlemail.com
And the email never sends...