douxiuyi6529 2016-10-25 16:19
浏览 259
已采纳

HTML表单没有发布? 有名字字段吗?

I feel like an absolute moron posting this question, but I'm completely serious, I officially have NO idea why this form isn't posting. I've gone from using AJAX to display information inputted to simple submit-redirect-grab Post data in PHP to $_SERVER["PHP_SELF"] trying to get the information to JUST POST, and it won't. Most of the people asking this question have had their answers revealed as "You need a name field" or "Your javascript is the issue" but I have a name field and I am no longer using javascript. I am utterly and completely confused.

For reference, I'm using PHPStorm and a Local server to test this out. I just logged on fresh today, saved the project, ran it for the first times today, made sure it wasn't just a sort of cached project, and it doesn't appear to have anything with old data.

Please don't mind if some of the form syntax is messy, I just want this darn post to work so I can move on to the meat of what I'm trying to make. Also there is no stylesheet currently, it's mostly empty apart from

.id {
    height: 100px;
}

Also none of the form fields are required, you really only need to enter information into one. I've got it doing a var_dump just so I can see all of the form post data, and it's brilliantly not working. I did have it echoing out something in PHP along the lines of "Done!" to show php is being read, and I also had it attempting to echo $_POST["modelnumber"] just to see that. Nope.

index.php

<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="index.css">
<body>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    Model Number:<br>
    <input type="text" id="mod" name="modelnumber"><br><br>
    Amazon Item?<br>
    <input type="radio" id="amazonItemY" name="amazonItem" value="yes"> Yes<br>
    <input type="radio" id="amazonItemN" name="amazonItem" value="no" checked> No<br><br>
    Item name:<br>
    <input type="text" id="intName" name="itemName"><br><br>
    Item Description:<br>
    <input type="text" id="internetDescription" name="description"><br><br>
    Brand:<br>
    <input type="text" id="brand" name="itemBrand"><br><br>
    Manufacturer:<br>
    <input type="text" id="manufacturer" name="manName"><br><br>
    Website category:<br>
    <input type="text" id="cmcategory" name="category"><br><br>
    Clearance?<br>
    <input type="radio" id="clearanceY" name="clearance" value="yes"> Yes<br>
    <input type="radio" id="clearanceN" name="clearance" value="no" checked> No<br><br>
    Competitor Price: (leave empty if not clearance)<br>
    <input type="text" id="competitorPrice" name="compPrice"><br><br>
    School price:<br>
    <input type="text" id="catStdPrice" name="schoolPrice"><br><br>
    Dealer price:<br>
    <input type="text" id="dealerStdPrice" name="dealerPrice"><br><br>
    Website price(normal):<br>
    <input type="text" id="intCsiPrice" name="webPrice"><br><br>
    Unit of Measure:<br>
    <input type="text" id="unitOfMeasure" name="uom"><br><br>
    UPC:<br>
    <input type="text" id="upc" name="upcNum"><br><br>
    Manufacturer Part Number:<br>
    <input type="text" id="mfgr_num" name="manfacNum"><br><br>
    Item Attribute:<br> <!--needs to be a dropdown-->
    <select id="attribute" name="attributes">
        <option value="(1593325)Baseball">Baseball</option>
        <option value="(1593326)Basketball">Basketball</option>
        <option value="(1593386)Boating + Paddling">Boating + Paddling</option>
        <option value="(1593314)Camping Hiking + Climbing">Camping_ Hiking + Climbing</option>
        <option value="(1610848)Cricket">Cricket</option>
        <option value="(1593313)Cycling">Cycling</option>
        <option value="(1593315)Equestrian">Equestrian</option>
        <option value="(1593318)Fishing">Fishing</option>
        <option value="(1593323)Football">Football</option>
        <option value="(1594100)General Sports Equipment + Accessories">General Sports Equipment + Accessories</option>
        <option value="(1593320)Golf">Golf</option>
        <option value="(1593319)Hunting + Archery">Hunting + Archery</option>
        <option value="(1593329)Ice + Roller Hockey">Ice + Roller Hockey</option>
        <option value="(1593327)Other Sports">Other Sports</option>
        <option value="(1593331)Personal Fitness">Personal Fitness</option>
        <option value="(1599122)Pool + Billiards">Pool + Billiards</option>
        <option value="(1593321)Rugby">Rugby</option>
        <option value="(1593317)Skateboarding + Rollerskating">Skateboarding + Rollerskating</option>
        <option value="(1593330)Ski + Snow">Ski + Snow</option>
        <option value="(1593322)Soccer">Soccer</option>
        <option value="(1593324)Softball">Softball</option>
        <option value="(1593316)Tennis">Tennis</option>
        <option value="(1593328)Water Sports">Water Sports</option>
    </select><br/>
    <input type="submit">
</form>

<?php
var_dump($_POST);
?>

</div>
  • 写回答

2条回答 默认 最新

  • douchi2022 2016-10-25 18:31
    关注

    RedRazor's answer is not a solution. The PHP interpreter resets the quotes inside of the php tags. This means that you can re-use the same quotes in the interpretation snippet.

    This seems more like a PHP Storm issue, try to restart your PHP Storm server. I copied your code exactly to my machine and used PHP Storm built in server. With no modifications your code worked. I've attached some images of my setup.

    Also you have to be running the PHP server to get $_POST requests, there is an icon to just open in the browser, which will work for many cases, but it will not work on requests like this due to their nature.

    Here are some images of my setup:

    123

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

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站