duanpie2414 2019-01-24 18:12
浏览 91
已采纳

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

My code was working just fine until I added some Radio button in the code. Now when I click the Submit button, the page gets stuck and the Submit button remains clicked without the data getting inserted into the db. I wanted the clicked value to be stored. Can someone tell where I'm wrong.

<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" button:

The page after I click Submit

</div>
  • 写回答

1条回答 默认 最新

  • dqcd84732 2019-01-24 18:16
    关注

    You have 2 form tags and you're only closing one of them.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀