php - Remember submitted field in form drop down list -


i have html form , php script on same page, calculates price based in input html form.

it important information provided in form stored when php script runs, customer can see price based on.

the following code stores text input:

<input type="number" min="1" max="420" name="stofprijs" width="100" placeholder="prijs"  value="<?=( isset( $_post['stofprijs'] ) ? $_post['stofprijs'] : '' )?>"> euro. 

i had tried store data drop down list code:

on top:

<?php     $gordijnsoort = $_post['gordijnsoort']; ?> 

in form:

<select name="gordijnsoort">     <option value="gordijn" <?php echo $gordijnsoort == 'gordijn' ? 'selected="selected"' : ''; ?>>gordijn</option>     <option value="vouwgordijn" <?php echo $gordijnsoort == 'vouwgordijn' ? 'selected="selected"' : ''; ?>>vouwgordijn</option>     <option value="ringgordijn" <?php echo $gordijnsoort == 'ringgordijn' ? 'selected="selected"' : ''; ?>>ringgordijn</option> </select> 

the data stored, empty form keeps displaying error:

undefined index: gordijnsoort

the form should save variable when customer submits form, it's looking variable @ start.

does know how fix this?

try this:

<?php     $gordijnsoort = array_key_exists('gordijnsoort', $_post) ? $_post['gordijnsoort'] : ""; ?> 

you receive error because @ first call $_post array empty , try access undefined key.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -