php post name & age to MySql database
Back to the basics.
I have a simple form to post in my database.
Can anybody suggest how I make a variable to catch the list selection and text field?
<form action="action.php" method="post">
<p>Your name: <span id="sprytextfield1">
<input type="text" name="name" />
<span class="textfieldRequiredMsg">A value is required.</span></span></p>
<p>Your age: <select name="age">
<option value="22">22</option>
<option>23</option>
<option>24</option>
<option>25</option>
</select></p>
<p><input type="submit" /></p>
</form>
then below is the action.php file that posts to the page first, and to the db.
It works except I don`t get the input values passed into the db.
I get name & age (no numbers and only the default `name`)
Hi <?php echo htmlspecialchars($_POST['name']); ?>.<br>
You are <?php echo (int)$_POST['age']; ?> years old.
<br><?php mysql_query("INSERT INTO example
(name, age) VALUES('name', 'age' ) ")
or die(mysql_error());
echo "Data Inserted!";?>
<form name="form1" method="get" action="form1.html">
<input type="submit" name="button" id="button" value="Done">
</form>
Thank you for any help!
