xxshadowxx Posted September 7, 2015 Share Posted September 7, 2015 (edited) Hi All, I would appreciate if someone can help me with the below coding: In HTML: <h4>Contact Form</h4> <div class="status alert alert-success" style="display: none"></div> <form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php"> <div class="row-fluid"> <div class="span5"> <label>First Name*</label> <input type="text" class="input-block-level" required="required" placeholder="Your First Name" method="post"> <label>Last Name*</label> <input type="text" class="input-block-level" required="required" placeholder="Your Last Name" method="post"> <label>Email Address*</label> <input type="text" class="input-block-level" required="required" placeholder="Your email address" method="post"> </div> <div class="span7"> <label>Telephone Number*</label> <input type="tel" class="input-block-level" required="required" placeholder="Your telephone number" method="post"> <label>Message*</label> <textarea name="message" id="message" required="required" class="input-block-level" rows="15" method="post"></textarea> </div> </div> <button type="submit" value="submit" class="btn btn-primary btn-large pull-right" method="post">Send Message</button> <p> </p> </form> In sendemail.php: <?php header('Content-type: application/json'); $status = array( 'type'=>'success', 'message'=>'Email sent!' ); $first_name = $_GET['first_name']; $last_name = $_GET['last_name']; $email = $_GET['email']; $subject = $_GET['subject']; $message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_GET['message']; $email_from = $_GET['email']; $email_to = 'example@example.com'; $body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message . ""; $success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>'); echo json_encode($status); die; Could someone tell me which part is wrong? I manage to receive email from contact form but no message is displayed in the mail as well as from the sender. Appreciate the prompt assistance. Yours Sincerely, Randy Edited September 7, 2015 by xxshadowxx Quote Link to comment https://forums.phpfreaks.com/topic/298084-help-needed-cant-get-form-details-in-email/ Share on other sites More sharing options...
QuickOldCar Posted September 7, 2015 Share Posted September 7, 2015 in your form: method="post" what you are looking for is $_GET, use the same method Quote Link to comment https://forums.phpfreaks.com/topic/298084-help-needed-cant-get-form-details-in-email/#findComment-1520409 Share on other sites More sharing options...
xxshadowxx Posted September 7, 2015 Author Share Posted September 7, 2015 Hi QuickOldCar, You're saying I should get, so which part of the form should I use get? Under HTML, <button type="submit" value="submit" class="btn btn-primary btn-large pull-right" method="post">Send Message</button> or ? Quote Link to comment https://forums.phpfreaks.com/topic/298084-help-needed-cant-get-form-details-in-email/#findComment-1520434 Share on other sites More sharing options...
QuickOldCar Posted September 7, 2015 Share Posted September 7, 2015 You're saying I should get, so which part of the form should I use get? No, I meant... If you are using post as the method in your form check for $_POST values. If you use get as the method in the form check for $_GET values. Quote Link to comment https://forums.phpfreaks.com/topic/298084-help-needed-cant-get-form-details-in-email/#findComment-1520447 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.