Highlighted

PHP + HTML Form: The email I receive does not show the info that the user types in

New Here ,
Aug 24, 2018

Copy link to clipboard

Copied

For some reason when a user submits this form, I'll get in an email back and only see the following:

From:

Email:

Address:

Here is my PHP file (note: I blocked my email address):

<?php

/* Set e-mail recipient */

$myemail = <My email goes here>

$subject = "Registration Form";

/* Check all form inputs using check_input function */

$first_name = $_POST['first_name'];

$last_name = $_POST['last_name'];

$address = $_POST['address'];

$city = $_POST['city'];

$state = $_POST['state'];

$zip = $_POST['zip'];

$tel = $_POST['tel'];

$email = $_POST['email'];

$dept = $_POST['dept'];

$course = $_POST['course'];

/* Let's prepare the message for the e-mail */

  $message = "Form details below.\n\n";

 

  $message = "From: $first_name\n E-Mail: $email\n Address:\n $address";

$subject ="Registration Form";

/* Send the message using mail() function */

mail($myemail, $subject, $message);

/* Redirect visitor to the thank you page */

header('Location: thanks.html');

exit();

/* Functions we used */

function check_input($data, $problem='')

{

  $data = trim($data);

  $data = stripslashes($data);

  $data = htmlspecialchars($data);

  if ($problem && strlen($data) == 0)

  {

  show_error($problem);

  }

  return $data;

}

function show_error($myError)

{

?>

  <html>

  <body>

  <b>Please correct the following error:</b><br />

  <?php echo $myError; ?>

  </body>

  </html>

<?php

exit();

}

?>

  function clean_string($string) {  $bad = array("content-type","bcc:","to:","cc:","href");  return str_replace($bad,"",$string);  }

Views

191

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

PHP + HTML Form: The email I receive does not show the info that the user types in

New Here ,
Aug 24, 2018

Copy link to clipboard

Copied

For some reason when a user submits this form, I'll get in an email back and only see the following:

From:

Email:

Address:

Here is my PHP file (note: I blocked my email address):

<?php

/* Set e-mail recipient */

$myemail = <My email goes here>

$subject = "Registration Form";

/* Check all form inputs using check_input function */

$first_name = $_POST['first_name'];

$last_name = $_POST['last_name'];

$address = $_POST['address'];

$city = $_POST['city'];

$state = $_POST['state'];

$zip = $_POST['zip'];

$tel = $_POST['tel'];

$email = $_POST['email'];

$dept = $_POST['dept'];

$course = $_POST['course'];

/* Let's prepare the message for the e-mail */

  $message = "Form details below.\n\n";

 

  $message = "From: $first_name\n E-Mail: $email\n Address:\n $address";

$subject ="Registration Form";

/* Send the message using mail() function */

mail($myemail, $subject, $message);

/* Redirect visitor to the thank you page */

header('Location: thanks.html');

exit();

/* Functions we used */

function check_input($data, $problem='')

{

  $data = trim($data);

  $data = stripslashes($data);

  $data = htmlspecialchars($data);

  if ($problem && strlen($data) == 0)

  {

  show_error($problem);

  }

  return $data;

}

function show_error($myError)

{

?>

  <html>

  <body>

  <b>Please correct the following error:</b><br />

  <?php echo $myError; ?>

  </body>

  </html>

<?php

exit();

}

?>

  function clean_string($string) {  $bad = array("content-type","bcc:","to:","cc:","href");  return str_replace($bad,"",$string);  }

Views

192

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 24, 2018 0
Adobe Community Professional ,
Aug 25, 2018

Copy link to clipboard

Copied

The HTML form must contain the exact same names as your script.

Nancy O'Shea, ACP
Alt-Web Design & Publishing

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2018 1