/    Sign up×
Community /Pin to ProfileBookmark

form not receiving all the fields to the email

I have created a form using PHP. and I am unable to receive all the forms fields .. only message the message field input is receiving to my email.

Below is my code.
[B]
form.php[/B]

[CODE]

<?php include(‘form_process.php’); ?>
=
<link rel=”stylesheet” href=”form.css” type=”text/css”>
<div class=”container”>
<form id=”contact” action=”<?= htmlspecialchars($_SERVER[“PHP_SELF”]) ?>” method=”post”>
<h3>Contact</h3>
<h4>Contact us today, and get reply with in 24 hours!</h4>
<fieldset>
<input placeholder=”Your name” type=”text” name=”name” value=”<?= $name ?>” tabindex=”1″ autofocus>
<span class=”error”><?= $name_error ?></span>
</fieldset>
<fieldset>
<input placeholder=”Your Email Address” type=”text” name=”email” value=”<?= $email ?>” tabindex=”2″>
<span class=”error”><?= $email_error ?></span>
</fieldset>
<fieldset>
<input placeholder=”Your Phone Number” type=”text” name=”phone” value=”<?= $phone ?>” tabindex=”3″>
<span class=”error”><?= $phone_error ?></span>
</fieldset>
<fieldset>

<fieldset>
<textarea value=”<?= $message ?>” name=”message” tabindex=”4″ placeholder=”No of adults, No of children and Date for ride” >
</textarea>
</fieldset>
<fieldset>
<button name=”submit” type=”submit” id=”contact-submit” data-submit=”…Sending”>Submit</button>
</fieldset>
<div class=”success”><?= $success ?></div>
</form>
</div>

[/CODE]

[B]

form_process.php[/B]

[CODE]

<?php

// define variables and set to empty values
$name_error = $email_error = $phone_error = “”;
$name = $email = $phone = $message = $success = “”;

//form is submitted with POST method
if ($_SERVER[“REQUEST_METHOD”] == “POST”) {
if (empty($_POST[“name”])) {
$name_error = “Name is required”;
} else {
$name = test_input($_POST[“name”]);

// check if name only contains letters and whitespace
if (!preg_match(“/^[a-zA-Z ]*$/”,$name)) {
$name_error = “Only letters and white space allowed”;
}

}

if (empty($_POST[“email”])) {
$email_error = “Email is required”;
} else {
$email = test_input($_POST[“email”]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$email_error = “Invalid email format”;
}
}

if (empty($_POST[“phone”])) {
$phone_error = “Phone is required”;
} else {
$phone = test_input($_POST[“phone”]);
// check if e-mail address is well-formed
if (!preg_match(“/^(d[s-]?)?[([s-]{0,2}?d{3}[)]s-]{0,2}?d{3}[s-]?d{4}$/i”,$phone)) {
$phone_error = “Invalid phone number”;
}
}

if (empty($_POST[“message”])) {
$message = “”;
} else {
$message = test_input($_POST[“message”]);
}

if ($name_error == ” and $email_error == ” and $phone_error == ”){
$message_body = ”;

unset($_POST[‘submit’]);
foreach ($_POST as $key => $value){
$message_body .= “$key: $valuen”;
$phone.=”$KEY: $value”;

}

$to = ‘[email protected]’;
$subject = ‘Contact Form Submit’;

‘Reply-To: [email protected]’;
if (mail($to, $subject, $message) ){
$success = “Message sent, thank you for contacting us!”;
$name = $email = $phone = $message = ”;
}
}

}

function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}

[/CODE]

A help is much appreciated ..
Thanks

to post a comment
HTML

0Be the first to comment 😎

×

Success!

Help @Izzybizzy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...