Jump to content

Recommended Posts

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 by xxshadowxx

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.