2013-05-20 20:53


  • post
  • submit
  • php
  • forms

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 -->
    <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>
    <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>
    <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 class="alignRight" style="font-weight:bold;">Options:</td>
    <td width="10px"></td>
    <td colspan="4">
        Power Windows, 
            Power Locks, 
            Keyless Entry, 
            Cruise Control, 
            Climate Control, 
            2.6L V-Tech
    <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>
<td class="alignRight"></td>
<td><a href="#top">Back to Top</a></td>
        <td class="alignRight" style="font-weight:bold;">Price:</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>

    </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?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • doudun3910 doudun3910 8年前

    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.


    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

    点赞 评论 复制链接分享
  • doudiejian5827 doudiejian5827 8年前

    You are not posting anything. But, If you want to maintain your structure and actually post something. Add some hidden inputs with the values you want to post.

    Your inputs would go like this:

    <input type="hidden" name="carYear" value="2011"/>
    <input type="hidden" name="carMake" value="Honda"/>
    <input type="hidden" name="carModel" value="Accord"/>
    <input type="hidden" name="carColor" value="Red"/>
    点赞 评论 复制链接分享
  • doudaotui4297 doudaotui4297 8年前

    You don't have any input in your form except for the submit button, this is the reason why you don't get any data in

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

    To have a value let's say in $_POST['carYear'] you should add somewhere in your form

    <input type="text" name="carYear">

    Learn more about php forms here

    点赞 评论 复制链接分享