0

PHP again guys.....

I thought this code was supposed to send an email to me..... but i didn't get any when i ran the code or do i have to host before it works?? here is the code: $sql = $mysqli->query("INSERT INTO users(firstname,lastname,username,email,password,vkey) VALUES('$fname','$lname','$uname','$email','$password','$vkey')"); if ($sql) { // send verification maessage to email $to = $email; $subject = "Email Verification"; $message = "<a href='http://localhost/project3/verify.php?vkey=$vkey'>Verify Account</a>"; $headers = "From: iksteve247@gmail.com \r\n"; $headers .= "MIME_Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; mail($to,$subject,$message,$headers); header('location:thankyou.php'); }else{ echo $mysqli->error; } i don't know what went wrong

17th Dec 2018, 11:23 AM
Okoro Ikechukwu Stephen
Okoro Ikechukwu Stephen - avatar
3 Respuestas
+ 2
So is it inserting in the DB? If not then the issue lays outside of the if($sql). Also I would guess that your headers are wrong. See mine below. Try this code just on its own on a test page and just change the recipient to a written address for testing. Also check your spam folder as this will likely end up being spammed. PhpMailer is the best option. $recipient = $email; $subject = 'User Contact Information'; $headers = "From: "no-reply@something.com"\r\n"; $headers .= "Reply-To: "no-reply@something.com"\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $body = 'Hi '.$_POST["uname"].', thanks for sending us an email.'; mail($recipient, $subject, $body, $headers) or die ("Failure");
17th Dec 2018, 4:34 PM
ihateonions
0
it's inserting into the DB but the mail is not coming....
17th Dec 2018, 7:45 PM
Okoro Ikechukwu Stephen
Okoro Ikechukwu Stephen - avatar
0
Let me try your code alone. ..thanks
17th Dec 2018, 7:47 PM
Okoro Ikechukwu Stephen
Okoro Ikechukwu Stephen - avatar