Jump to content


Sending Email - Script 8.10


  • Please log in to reply
2 replies to this topic

#1 tri



  • Members
  • Pip
  • 3 posts

Posted 5 January 2018 - 10:27 AM

Hi, I am using Xampp 3.2.2 and have written script 8.10 below (Page 228) but I just can´t get an e-mail. Everything looks fine but I get no e-mail at all. PIease help!
<?php // Script 8.10 - 19_register.php
/*This page lets people register for the site in theory*/
//Set the page title and include the header file:
define ('TITLE', 'Register');
include ('templates/19_header_v6.html');
//print some introductory text:
print '<div id = "leftcontent">
<h2>Registration Form</h2>
<p>Register so that you can take advantages of certain features like this, that and the other thing.</p>';
//Check whether the form has been submitted (handle form if):
$problem = false;
//Check for each value:
if (empty ($_POST['first_name'])){
$problem = TRUE;
print '<p class="text--error">Please enter your first name!</p>';
if (empty ($_POST['last_name'])){
$problem = TRUE;
print '<p class="text--error">Please enter your last name!</p>';
// Change the email validation(from 19_rigister_v11.php file) so that it also checks for a single "at" symbol:
if (empty ($_POST['email']) || (substr_count ($_POST['email'], '@')!=1)){
$problem = TRUE;
print '<p class="text--error">Please enter your email!</p>';
//Validate the password:
if (empty ($_POST['password1'])){
$problem = TRUE;
print '<p class="text--error">Please enter your password!</p>';
if ($_POST['password1'] != $_POST['password2']){
$problem = TRUE;
print '<p class="text--error">Your password did not match your confirmed password!</p>';
// Check whether a problem occured:
if (!$problem){
print '<p>You are now registered!<br />Okay, you are not really registered but ...</p>';
//Send the email:
$body = "Thank you, {$_POST['first_name']}, for registering with the J.D. Salinger fan club!";
mail($_POST['email'], 'Registration Confirmation', $body, 'From:me@example.com');
}else{ //Forgot a field
print '<p>Please try again!</>';
/*if (!problem){ // if there weren´t any problems ...
print '<p class ="text--success">You are now registered!<br />Okay, you are not really registerd but ...</p>';
//$_POST = [];
}else{//Forgot a field:
print '<p class = "text--error">Please try again!</p>';
} // End of handle form if: if ($_SERVER['REQUEST_METHOD'] =='POST'){
<!--Display the form-->
<form action="19_register_v12.php" method="post" class="form--inline">
<!-- Create the sticky first name, last name and email inputs-->
<p><label for="first_name">First Name: </label><input type="text" name="first_name" size="20" value="<?php if (isset($_POST['first_name'])){
print htmlspecialchars($_POST['first_name']);
<p><label for="last_name">Last Name: </label><input type="text" name="last_name" size="20" value="<?php if (isset($_POST['last_name'])){
print htmlspecialchars($_POST['last_name']);
<p><label for="email">Email Address: </label><input type="email" name="email" size="20" value="<?php if (isset($_POST['email'])){
print htmlspecialchars($_POST['email']);
Password: <input type = "password" name = "password1" size = "20"/><br /><br />
Confirm Password: <input type = "password" name = "password2" size = "20" /><br /><br />
<p><input type="submit" name="submit" value="Register!" class="button--pill"></p>
print '</div>';
require ('templates/19_footer_v6.html');

  • 0

#2 Larry



  • Administrators
  • 4840 posts
  • LocationState College, PA (USA)

Posted 6 January 2018 - 4:44 PM

What operating system are you using? And also make sure you use a real "from" email address as that can cause problems.

  • 0

#3 tri



  • Members
  • Pip
  • 3 posts

Posted 10 January 2018 - 10:08 AM

Hi, Larry.


Sorry for my late feedback.


I am using Windows 7 and my e-mail from gmail  but I cann´t just the email. Please see below the last message I got:


Warning: mail(): SMTP server response: 553 We do not relay non-local mail, sorry. in C:\XAMPP\htdocs\19_register_v12.php on line 51


Thanks a lot,



  • 0