1

I am recently getting into php and am running it locally on Xampp. I have created the following simple form followed by a few lines of php. It seems that no data is being passed through from the html form to the php page.

<form method="post" action="emailform.php" enctype="text/plain" class="form-horizontal">
    <div class="row input">
        <div class="col-md-1"></div>
        <div class="col-md-10">
            <div class="form-group">
                <input type="text" name="subject" id="subject" class="form-control" placeholder="subject">
            </div>
        </div>
    </div>
    <div class="row input">
        <div class="col-md-1"></div>
        <div class="col-md-4">
            <div class="form-group">
                <input type="text" name="name" id="name" class="form-control" placeholder="full name">
            </div>
            <div class="form-group">
                <input type="email" name="subject" id="email" class="form-control" placeholder="email">
            </div>
        </div>
        <div class="col-md-1"></div>
        <div class="col-md-5 textarea">
            <textarea class="form-control" name="message" id="message" rows="4" placeholder="message"></textarea>
        </div>
    </div>
    <br>
    <div class="row">
        <div class="col-md-1"></div>
        <div class="col-md-10">
            <button type="submit" class="btn" id="submit">Send</button>
        </div>
    </div>
</form>

This is the simple php code I am using to test:

<?php            
        $subject = 'No subject was set';
        if (isset($_POST['subject'])) {
            $subject = ($_POST['subject']);
        }
        echo "This is the subject:$subject"; 
    ?>

I appreciate any help as I have been struggling with this simple code for the past week now.

6
  • does all two files in same directory ? Commented Nov 12, 2015 at 9:54
  • 2
    remove enctype="text/plain" from form Commented Nov 12, 2015 at 9:54
  • Yes both files are in the same directory Commented Nov 12, 2015 at 9:55
  • 2
    two subject names! <input type="email" name="subject" id="email" class="form-control" placeholder="email"> and <input type="text" name="subject" id="subject" class="form-control" placeholder="subject"> Commented Nov 12, 2015 at 9:55
  • I have removed the enctype attribute but still the same result Commented Nov 12, 2015 at 9:56

1 Answer 1

1

Two subject names!

<input type="email" name="subject" id="email" class="form-control" placeholder="email">
                          ^

and

<input type="text" name="subject" id="subject" class="form-control" placeholder="subject">
                         ^

Also remove enctype="text/plain" from the form

It's because PHP doesn't handle it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.