由于单选按钮错误,我的数据未插入数据库

时间:2019-01-24 18:12:53

标签: php html mysql wordpress

我的代码运行良好,直到我在代码中添加了一些单选按钮。现在,当我单击“提交”按钮时,页面被卡住,并且“提交”按钮保持单击状态,而数据没有插入到数据库中。我希望存储单击的值。有人可以告诉我我错了吗。

<html>
    <hr />

    <form action="" method="post"><label>Client Name :</label>
        <input id="name" name="Name" required="required" type="text" placeholder="Please Enter Name" /><label>Aadhar :</label>

        <input id="Aadhar" name="Aadhar" type="text" placeholder="Please enter Aadhar Number" minlength=12 maxlength=12 />

        <label>Mobile :</label>
        <input id="Mobile" name="Mobile" required="required" type="text" placeholder="Please Enter Mobile Number" minlength=10 maxlength=10 />

        <label>Email ID :</label>
        <input id="Email" name="Email" type="text" placeholder="Please Enter Email ID" />

        <label>PAN :</label>
        <input id="PAN" name="PAN" type="text" placeholder="Please Enter PAN Number" minlength=10 maxlength=10 />

        <label>Date of Birth :</label>
        <input id="DOB" name="DOB" type="date" placeholder="Please Enter Date of Birth" />

        <label>GST  :</label>
        <input id="GST" name="GST" type="text" placeholder="Please Enter Mobile GST Number" minlength=15 maxlength=15 />

        <label>Type :</label>
        <form name="Type" action ="" method ="post">
            <input type="radio" name="Type" value="Individual"> Individual<br>
            <input type="radio" name="Type" value="Firm"> Firm<br>
            <input type="radio" name="Type" value="Company"> Company <br>  
            <input type="radio" name="Type" value="Trust"> Trust <br>
            <input type="radio" name="Type" value="Others"> Others 
        </form>

        <label>Company :</label>
        <input id="Company" name="Company" type="text" placeholder="Please Enter Company" />

        <label>Address :</label>
        <input id="Address" name="Address" type="text" placeholder="Please Enter Address" />

        <label>Description :</label>
        <input id="Description" name="Description" type="text" placeholder="Please Enter Description" />

        <input name="submit" type="submit" value=" Submit " />
    
    <?php
        $Name= $_POST['Name'];
        $Aadhar  = $_POST['Aadhar'];  
        $Mobile  = $_POST['Mobile'];  
        $Email  = $_POST['Email']; 
        $PAN  = $_POST['PAN']; 
        $DOB  = $_POST['DOB']; 
        $GST  = $_POST['GST']; 

        $Type  = $_POST['Type']; 
        $Company  = $_POST['Company'];  
        $Address  = $_POST['Address']; 
        $Description  = $_POST['Description'];  

        global $wpdb; 
        $table_name = $wpdb->prefix . "clients"; 

        $wpdb->insert('clients', [
                'Name'     => $_POST['Name'],
                'Aadhar'   => $_POST['Aadhar'],
                'Mobile'   => $_POST['Mobile'],
                'Email'    => $_POST['Email'],
                'PAN'     => $_POST['PAN'],
                'DOB'    => $_POST['DOB'],
                'GST'    => $_POST['GST'],
                'Type'    => $_POST['Type'],
                'Company' => $_POST['Company'], 
                'Address'  => $_POST['Address'],
                'Description'  => $_POST['Description']
            ],
            ['%s','%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s']
        );
    ?>
</html>

点击“提交”按钮后的页面:

The page after I click Submit

1 个答案:

答案 0 :(得分:0)

您有2个表单标签,而您只关闭其中之一。