Muiter
Muiter

Reputation: 1520

Form not submitting html

I am trying to get an simple email form to work. It is not responding to my submit button. What did I do wrong or is there something I left out?

                            <?php
                                    if($error == 'ja')
                                    {
                                        // maak random getallen voor anti spam
                                        $spam_1 = rand(1,10);
                                        $spam_2 = rand(1,10);
                                        $spam = 'Anti spam beveiliging, wat is het antwoord op deze som: '.$spam_1.' + '.$spam_2.' =';
                                        ?>

                                        <form method="post" action="?">
                                            <div class="row uniform 50%">
                                                <div class="6u 12u$(xsmall)"><input type="text" name="name" id="name" placeholder="Name" <?php if($error_name == 'ja') {echo 'style="border:1px solid #E41C2E"';} ?> /></div>
                                                <div class="6u$ 12u$(xsmall)"><input type="email" name="email" id="email" placeholder="Email" <?php if($error_email == 'ja') {echo 'style="border:1px solid #E41C2E"';} ?> /></div>
                                                <div class="12u$"><textarea name="message" id="message" placeholder="Message" rows="4" <?php if($error_message == 'ja') {echo 'style="border:1px solid #E41C2E"';} ?> ></textarea></div>
                                            </div>
                                        </form>
                                        <ul class="actions">
                                            <li><input type="submit" value="Send Message" /></li>
                                        </ul>
                                    </div>
                                    </form>
                                    <?php
                                }

                                    ?>
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
    echo 'working';
}

enter image description here

Upvotes: 0

Views: 56

Answers (2)

user7209225
user7209225

Reputation:

Include your submit field within the form.

Upvotes: 4

Bart Bergmans
Bart Bergmans

Reputation: 4121

Your submit button it outside the form. Please try this:

<form method="post" action="?">
    <div class="row uniform 50%">
        <div class="6u 12u$(xsmall)"><input type="text" name="name" id="name" placeholder="Name" <?php if($error_name == 'ja') {echo 'style="border:1px solid #E41C2E"';} ?> /></div>
        <div class="6u$ 12u$(xsmall)"><input type="email" name="email" id="email" placeholder="Email" <?php if($error_email == 'ja') {echo 'style="border:1px solid #E41C2E"';} ?> /></div>
        <div class="12u$"><textarea name="message" id="message" placeholder="Message" rows="4" <?php if($error_message == 'ja') {echo 'style="border:1px solid #E41C2E"';} ?> ></textarea></div>
    </div>
    <ul class="actions">
        <li><input type="submit" value="Send Message" /></li>
    </ul>
</form>

Upvotes: 0

Related Questions