CBaZ Posted April 3, 2009 Share Posted April 3, 2009 I need to see more then just the message in the email. I want to be able to see persons phone preferred method of communication etc. it echos it out after submit above the form but not in email someone have the answer ?? <div id="header"> </div> <body> <div id="centerContent"> <?php // If the form has been posted, analyse it: if ($_POST) { foreach ($_POST as $field => $value) { $value = trim($value); } // Creating Variables $inquiry=$_POST['inquiry']; $title=$_POST['title']; $first_name=$_POST['first_name']; $last_name=$_POST['last_name']; $email=$_POST['email']; $phone=$_POST['phone']; $message=$_POST['message']; $reply=$_POST['reply']; $contact=$_POST['contact']; // Create empty ERROR variables $error = ""; // for fields left BLANK $errorflag = ""; // for fields with INVALID data entered // Check for field/fields that is/are left BLANK if (($first_name == "") || ($last_name == "") || ($email == "") || ($phone == "") || ($message == "")) { $error = "<span class='colorTextBlue'>Please fill in all fields!</span>"; } else { // Validate First Name (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered if (ctype_alpha($first_name) == FALSE) { $error = "<span class='colorTextBlue'>Please enter a valid First Name <span class='italic'>(Alphabets only)</span></span>"; $errorflag= "first_name"; } // Validate Last Name (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered else if (ctype_alpha($last_name) == FALSE) { $error = "<span class='colorTextBlue'>Please enter a valid Last Name <span class='italic'>(Alphabets only)</span></span>"; $errorflag="last_name"; } // Validate E-mail (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered else if ((strpos($email, "@") == FALSE)|| (strpos($email, ".") == FALSE) || (strpos($email, " ") != FALSE)) { $error = "<span class='colorTextBlue'>Please enter a valid E-mail</span>"; $errorflag="email"; } // Validate Contact No. (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered else if (is_numeric($phone) == FALSE) { $error = "<span class='colorTextBlue'>Please enter a valid Phone No. <span class='italic'>(must contain numbers only)</span></span>"; $errorflag="phone"; } } // Confirmation Message seen AFTER filling the form and pressing "Submit" button (whether there's an error or not) if ($error != "") { echo "<br/> <b><span class='colorTextRed'>Error Occured: </b>" . $error."</span>" ; } // If there's an error along with displaying the list of flagged error/errors // If there's NO error at all, along with displaying the filled fields else if (mail("[email protected]", $_POST['inquiry'], $first, $last, stripslashes($_POST['message']), "From: " . $_POST['email'])) { echo "E-mail sent successfully"; echo "<p>Thanks for your comment and time. We will be in touch with you shortly, if required.<br/><br/>"; echo "<b>Nature of Inquiry:</b> ". $inquiry . "<br/>"; echo "<b>Title:</b> ". $title . "<br/>"; echo "<b>First Name:</b> ". $first_name . "<br/>"; echo "<b>Last Name:</b> ". $last_name . "<br/>"; echo "<b>E-mail:</b> ". $email . "<br/>"; echo "<b>Phone No.:</b> ". $phone . "<br/>"; echo "<b>Message:</b> ". $message . "<br/>"; echo "<b>Reply:</b> ". $reply . "<br/>"; echo "<b>Contact Method:</b> ". $contact . "<br/></p>"; } else { $error = "E-mail NOT sent"; } } // Displays the Empty variables else { $inquiry = ""; $title = ""; $first_name = ""; $last_name = ""; $email = ""; $phone = ""; $message = ""; $reply = ""; $contact = ""; $errorflag = ""; } ?> <p class="first-letter">Please fill the following form in for any enquiries that you may have:</p> <table id="contactTable"> <tr id="contactTable"> <td id="contactTable"><form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> Nature of Enquiry:</td> <td id="contactTable"><select name="inquiry" class="contactForm"> <option <?php if ($inquiry == "General Inquiry") echo "Selected"; ?> value = "General Inquiry">General Inquiry</option> <option <?php if ($inquiry == "Price Quotation") echo "Selected"; ?> value = "Price Quotation">Price Quotation</option> <option <?php if ($inquiry == "Comments") echo "Selected"; ?> value = "Comments">Comments</option> <option <?php if ($inquiry == "Other") echo "Selected"; ?> value = "Other">Other</option> </select></td> </tr> <tr id="contactTable"> <td id="contactTable">Title:</td> <td id="contactTable"><select name="title" class="contactForm"/> <option <?php if ($title == "Mr") echo "Selected"; ?> value = "Mr">Mr</option> <option <?php if ($title == "Miss") echo "Selected"; ?> value = "Miss">Miss</option> <option <?php if ($title == "Ms") echo "Selected"; ?> value = "Ms">Ms</option> <option <?php if ($title == "Mrs") echo "Selected"; ?> value = "Mrs">Mrs</option> <option <?php if ($title == "Other") echo "Selected"; ?> value = "Other">Other</option> </select></td> </tr> <tr id="contactTable"> <td id="contactTable"><?php if ($errorflag == "first_name") { echo "<span class='colorTextRed'>First Name:</span>"; } else { echo "First Name:"; } ?></td> <td id="contactTable"><input type="text" size="30" maxlength="30" name="first_name" value="<?php echo $first_name; ?>" class="contactForm"/></td> </tr> <tr id="contactTable"> <td id="contactTable"><?php if ($errorflag == "last_name") { echo "<span class='colorTextRed'>Last Name:</span>"; } else { echo "Last name:"; } ?></td> <td id="contactTable"><input type="text" size="30" maxlength="30" name="last_name" value="<?php echo $last_name; ?>" class="contactForm"/></td> </tr> <tr id="contactTable"> <td id="contactTable"><?php if ($errorflag == "email") { echo "<span class='colorTextRed'>E-mail:</span>"; } else { echo "E-mail:"; } ?></td> <td id="contactTable"><input type="text" size="30" maxlength="30" name="email" value="<?php echo $email; ?>" class="contactForm"/></td> </tr> <tr id="contactTable"> <td id="contactTable"><?php if ($errorflag == "phone") { echo "<span class='colorTextRed'>Phone No.:</span>"; } else { echo "Phone No.:"; } ?></td> <td id="contactTable"><input type="text" size="30" maxlength="20" name="phone" value="<?php echo $phone; ?>" class="contactForm"/></td> </tr> <tr id="contactTable"> <td id="contactTable">Message:</td> <td id="contactTable"><textarea rows="10" cols="50" wrap="physical" name="message" class="contactForm"/><?php echo $message; ?> </textarea></td> </tr> <tr id="contactTable"> <td id="contactTable">Reply Required:</td> <td id="contactTable"><input type="radio" name="reply" value="Yes" checked="checked"/>Yes <input type="radio" name="reply" value="No" <?php if ($reply=="No") echo "checked='checked'"; ?>/>No</td> </tr> <tr id="contactTable"> <td id="contactTable">How would you like to be contacted <span class="italic">(if required)</span>?<br/><br/></td> <td id="contactTable"><input type="radio" name="contact" value="Email" checked="checked"/>E-mail <input type="radio" name="contact" value="Telephone" <?php if ($contact="Telephone") echo "checked='checked'"; ?>/>Telephone </td> </tr> <tr id="contactTable"> <td id="contactTable"></td> <td id="contactTable"><input type="reset" name="reset" value="Reset"> <input type="submit" name="submit" value="Submit"></td> </form> </tr> </table> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/152325-form-issues/ Share on other sites More sharing options...
sh0wtym3 Posted April 3, 2009 Share Posted April 3, 2009 Change this: // If there's NO error at all, along with displaying the filled fields else if (mail("[email protected]", $_POST['inquiry'], $first, $last, stripslashes($_POST['message']), "From: " . $_POST['email'])) { To this: // If there's NO error at all, along with displaying the filled fields $newmessage = 'Name: '.$first_name.' '.$last_name.'<br>Phone: '.$phone.'<br>Email: '.$email.'<br><br>Message: '.$message.'<br><br>Reply? '.$reply.'<br>Preferred Method of Communication: '.$contact; else if (mail("[email protected]", $_POST['inquiry'], $newmessage, "From: " . $_POST['email'])) { Link to comment https://forums.phpfreaks.com/topic/152325-form-issues/#findComment-799992 Share on other sites More sharing options...
sh0wtym3 Posted April 3, 2009 Share Posted April 3, 2009 ... and let me know if it works Link to comment https://forums.phpfreaks.com/topic/152325-form-issues/#findComment-799994 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.