dongyin5516 2013-05-20 20:53
浏览 91
已采纳

php表单提交无效

I have multiple pages that I have made using this exact same method, but for some reason, no matter what I've tried, I can't get certain fields to transfer into the email fields. I get absolutely no data at all. Here is the form HTML

    <form action="interest.php" method="post" >                                                   <!-- BEGIN cardetail Form -->
    <table>
    <tr>
    <td width="50" class="alignRight" style="font-weight:bold;" >Year:</td>
    <td width="10px"></td>
    <td width="112"><p name="carYear">2011</p></td>
    <td class="alignRight" style="font-weight:bold;" >Color:</td>
    <td width="10px"></td>
    <td><p name="carColor">Red</p></td>
    </tr>
    <tr>
    <td class="alignRight" style="font-weight:bold;" >Make:</td>
    <td width="10px"></td>
    <td ><p name="carMake">Honda</p></td>
    <td width="50" class="alignRight" style="font-weight:bold;">Trim:</td>
    <td width="10px"></td>
    <td>Car has some sort of trim on it.</td>
    </tr>
    <tr>
    <td class="alignRight" style="font-weight:bold;" >Model:</td>
    <td width="10px"></td>
    <td><p name="carModel">Accord</p></td>
    <td class="alignRight" style="font-weight:bold;">Miles:</td>
    <td width="10px"></td>
    <td><p>180,000</p></td>
    </tr>
    <tr>

    </tr>
    <tr>
    <td class="alignRight" style="font-weight:bold;">Options:</td>
    <td width="10px"></td>
    <td colspan="4">
    <p>
        Power Windows, 
            Power Locks, 
            Keyless Entry, 
            Cruise Control, 
            Climate Control, 
            2.6L V-Tech
    </p>
    </td>
    </tr>
    <tr>
    <td style="font-weight:bold;">Repairs/Maintenance:</td>
    <td width="10px"></td>
    <td colspan="4">Fuel line flush, Transmission flush, Coolant flush, Oil Change, New Oil Filter, New Fuel Filter, New Air Filter, New Radiator, Painted Driverside Door, New Tires, Brand New Wax Job, and Fully Detailed.</td>
    </tr>
    <tr>
<td class="alignRight"></td>
        <td></td>
<td><a href="#top">Back to Top</a></td>
        <td class="alignRight" style="font-weight:bold;">Price:</td>
        <td></td>
        <td class="price"><p><span class="price"><?php echo $carPrice; ?>$6,000</span><input class="showInterest" type="submit" name="showInterest" id="showInterest" value="Show Interest" /></td>
    </tr>

    </table>
    </form>                     <!-- END cardetail Form -->

Here is the php code that I'm trying to get the information transferred to.

    <?php echo $_POST['carYear'] . " / " . $_POST['carMake'] . " / " . $_POST['carModel'] . " / " . $_POST['carColor']; ?>

Now when I run the code from my server, all I get is 3 "/". For some reason the $_POST isn't grabbing any data. I've tried passing it into a variable, AND just inserting the data as it is in the example. What am I doing wrong? Is there a minor typo that I'm missing?

  • 写回答

3条回答 默认 最新

  • doudun3910 2013-05-20 21:02
    关注

    Why you are not getting anything is because, you are not posting anything!!

    You only have one <input> and it is this one:

      <input class="showInterest" type="submit" name="showInterest"
                   id="showInterest"  value="Show Interest" />
    

    And, that is just a submit button only, It does nothing by itself. It can only submit what is inside another <input type=''> tag. ex: if you have

    <input type='text' name='carYear' /> You would be able to retrieve the value by saying echo $_POST['carYear']; in your PHP page.

    I don't see anything there. You can't post a plain text, no matter if it is inside your <form></form> tags. You have to create inputs.

    edited

    Ok, put this values scripts your HTML file,

      <input type='text' name='carYear' value='' />
      <input type='text' name='carMake' value='' />
      <input type='text' name='carModel' value='' />
      <input type='text' name='carColor' value='' />
    

    and fill all the value='' with the car details, and submit the form

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问