Reputation: 1044
I have this code here, within a form:
<form method="post" action="">
<div id="icon-themes" class="icon32"><br></div>
<h2 class="nav-tab-wrapper"><a class='nav-tab' href='?page=symbiostock-ecommerce-manager&tab=homepage'>Home Settings</a><a class='nav-tab nav-tab-active' href='?page=symbiostock-ecommerce-manager&tab=invoices'>Invoices</a><a class='nav-tab' href='?page=symbiostock-ecommerce-manager&tab=VAT'>VAT Settings</a><a class='nav-tab' href='?page=symbiostock-ecommerce-manager&tab=feed'>Google Product Feed</a></h2>
<br />
<label for="ssem_year_num">Year
<input name="ssem_year_num" value="2014" type="text" />
</label>
<label for="ssem_month_num">
Month
<select name="ssem_month_num">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option selected value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
</label>
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes" /></p>
</form>
Despite changing the values in the text and select area, they do not seem to change upon form submission, as the var_dump($_POST)
result shows this:
array (size=3)
'ssem_year_num' => string '2014' (length=4)
'ssem_month_num' => string '8' (length=1)
'submit' => string 'Save Changes' (length=12)
Having run my HTML through the w3 validator, it appears the HTML is not broken, so I'm left wondering - why aren't the values reflecting user input upon submission?
Upvotes: 0
Views: 70
Reputation: 18416
Try to rename:
<input type="submit" name="submit" id="submit">
To
<input type="submit" name="s1" id="s1">
And see if that resolves the issue. I am assuming there is javascript on the page listening for a form.submit event.
Upvotes: 0
Reputation: 339
i think your problem is this: php is a preprocessed language.
If you are grabbing var_dump($_POST)
at the same page, nothing should be in $_POST
since when you load the php, you have not posted your form yet. therefore it will be empty.
put your php into seperate file and call it via action="submit.php"
, then use var_dump($_POST)
and see it works!
Upvotes: 0
Reputation: 148
for the input text try this:
<label for="ssem_year_num">Year
<input type="text" placeholder="2014" name="ssem_year_num" />
</label>
and in the select remove the 'selected' property:
....
<option value="8">August</option>
....
and see what happens.
Upvotes: 2