简体   繁体   English

单击提交按钮后没有任何反应

[英]nothing happens after clicking submit button

I can not figure out what i missed here in my code. 我无法弄清楚我在代码中错过了什么。 i if else statement is working because i can see my form and after submitting i suppose to see message after tag. 我是否其他语句正在工作,因为我可以看到我的表单,并且提交后我应该看到标记后的消息。 How would i know if submit button is respond or not. 我怎么知道提交按钮是否响应。

 <?php

$output_form = true;

$fname = "";
$lname = "";
$address1 ="";
$address2 ="";
$city = "";
$state = "";
$zipcode = "";

if (isset($_POST['submit'])) { 

print_r($_POST);

    $fname = trim($_POST["firstName"]);
    $lname = trim($_POST['lastName']);
    $address1 = trim($_POST['address1']);
    $address2 = trim($_POST['address2']);
    $city = trim($_POST['city']);
    $state = trim($_POST['state']);
    $zipcode = trim($_POST['zipcode']);

}

?>
<!DOCTYPE html>
<html>
    <head>
        <title>Assignment 3 </title>
        <link rel="stylesheet" type="text/css" href="style.css">

    </head>
    <body>

        <?php 
        if ($output_form) {
        ?>

        <h1>Enter your information</h1>

        <form name="userform" action="<?= $_SERVER['PHP_SELF'] ?>" method="post">

            <p>First Name: <input name="firstName" type="text" value="<?= $fname ?>"></p>
            <p>Last Name: <input name="lastName" type="text" value="<?= $lname ?>"></p>
            <p>Address 1: <input name="address1" type="text" value="<?= $address1 ?>"></p>
            <p>Address 2: <input name="address2" value="<?= $address2 ?>" type="text" ></p>
            <p>City: <input name="city" type="text" value="<?= $city ?>"></p>
            <p>State: <input name="state" type="text" value="<?= $state ?>"></p>
            <p>Zip Code: <input name="zipcode" type="number" value="<?= $zipcode ?>"></p>
            <input class="button" name="submit" type="button" value="Button">
        </form>
        <?php
            } else {

        ?>
                <h2>Your information is:</h2>
                <p class="result">
                Name: <?= $fname.' '.$lname ?><br>
                Street Address: <?= $address1 ?><br>
                City, State: <?=$city.' '.$state ?>
                </p>

        <?php
        }
        ?>

    </body>
</html>

Make your input type submit 使您的输入类型提交

<input class="button" name="submit" type="button" value="Button">

Should be 应该

<input class="button" name="submit" type="submit" value="Button">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM