Kitfoxpup Kitfoxpup - 1 month ago 6
HTML Question

HTML Form Not POSTing? Has name field?

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);
?>




Answer

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:

1 2 3

Comments