I’ve been trying to get a html and php file to work but every time it sends the email to my inbox it shows this: Hello!
Your subscribe form has been submitted by:
E-mail:
End of message
That is the layout I want but the E-mail: bit doesn’t have an email next to it.
Here’s my code:
Php:
<?php
/* Set e-mail recipient */
$myemail = "email@example.com";
/* Check all form inputs using check_input function */
$email = check_input($_POST['email']);
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
/* Let's prepare the message for the e-mail */
$message = "Hello!
Your subscribe form has been submitted by:
E-mail: $email
End of message
";
/* Send the message using mail() function */
mail($email);
/* 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();
}
?>
And obviously I replaced the email because I don’t want anyone to know what my email is.
Html:
<div class="demo2"></div>
<div class="content2-w3-agileits">
<form action="/contact.php" method="post" class="agile-info-form">
<input type="email" name="Email" class="email" placeholder="Enter your email address" required="">
<input type="submit" value="Send it">
<div class="Send"> </div>
</form>
</div>
All help appreciated.