Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
573 views
in Technique[技术] by (71.8m points)

php - $_POST is empty after form submit

I am using Twitter Bootstrap to build a web application. I have a form where user should enter his name and last name and click submit. The problem is, that the $_POST comes back empty. I am using WAMP on Windows 8 machine.

<?php
if(isset($_POST["send"])) {
    print_r($_POST)
} else {
    ?>
    <form class="form-horizontal" action="" method="post">
        <div class="control-group"> <!-- Firstname -->
            <label class="control-label" for="inputEmail">First name</label>
            <div class="controls">
                <input type="text" id="inputName" placeholder="First name">
            </div>
        </div>
        <div class="control-group"> <!-- Lastname -->
            <label class="control-label" for="inputEmail">last name</label>
            <div class="controls">
                <input type="text" id="inputLastname" placeholder="Last name">
            </div>
        </div>
        <div class="form-actions">
            <button type="submit" name="send" class="btn btn-primary">Submit data</button>
            <a href="<?php $mywebpage->goback(); ?>" class="btn">Cancel</a>
        </div>
    </form>
    <?php
}
?>

Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Plz try and add names to the input types like

<input type="text" id="inputLastname" name="inputLastname" placeholder="Last name">

Now check the $_POST variable.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...