ISSET 提交不起作用


isset submit is not working

我正在使用isset函数来检查是否单击了提交按钮,但它不起作用。它没有进入if.这是我的代码。我没有得到问题仍然存在的地方。

<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td><h2><br />
            User Registration</h2>
            <p>&nbsp;</p></td>
    </tr>
    <tr>
        <td>
            <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form1" id="form1" onsubmit="return Validate();">
                User Name[E-mail ID]: <input type="text" name="username" style="width:230px; height:20px;" /><br /><br />
                Password : <input type="password" name="password" style="width:230px; height:20px;" /><br /><br />
                Name <input type="text" name="name" style="width:230px; height:20px;" /><br /><br />
                Contact Number: <input type="text" name="phone" style="width:230px; height:20px;" /><br /><br />
                Email: <input type="text" name="email" style="width:230px; height:20px;" /><br /><br />
                <input type="submit" value="REGISTER" />
            </form>
            <?php
            include('connect.php');
            if (isset($_POST['submit']))
            {
                echo "1";
                $username = $_POST['username'];
                echo $username;
                $password = $_POST['password'];
                $name = $_POST['name'];
                $phone = $_POST['phone'];   
                $email = $_POST['email'];
                //$id = $_GET['aid'];
                $sql = "INSERT INTO user_info(application_id, username, password, name, contact, email) VALUES (" . $aid. ", " .$username.", ".$password.", ".$name.",". $phone.", ".$email.") ";
                echo $sql;
                mysql_query($sql) or die(mysql_error());
                //header("Location: index1.php");
            }
            ?>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
</table>

请让我知道我哪里出错了。

更改

<input type="submit" value="REGISTER" />

<input type="submit" name="submit" value="REGISTER" />
您需要

为提交按钮提供 name 属性

 <input type="submit" name="submit" value="REGISTER" />

您需要一个名称为 submit 的输入元素。

您可以为您的提交按钮指定此名称,例如

<input type="submit" value="REGISTER" name="submit" />

或者,您可以使用以下名称创建隐藏输入:

<input type="hidden"  name="submit" />

您可以改为测试表单是否已回发

if (count($_POST) > 0)
{
    //code
}

仅当至少有一个字段已回发时,这才应触发。