So. i've made a really simple form (learning the basics of mysql + php) to send someones name and age into one table and name and favourite food into another. It works but the only trouble is that it sends it four times. Like i'll press submit and then the information will appear in the database multiple times.
Anyway, this is the html form code:
<form action="sent.php" method="get">
Forename: <input type="text" name="fname" /><br/>
Age: <input type="text" name="age" /><br/>
Favourite Food: <input type="text" name="fav_food" /><br/>
<input type="submit" value="Submit to database"/>
</form>
and this is the php:
<?php
mysql_connect("localhost", "admin", "1admin")
or die(mysql_error());
mysql_select_db("test")
or die(mysql_error());
$name = $_GET['fname'];
$age = $_GET['age'];
$fav_food = $_GET['fav_food'];
mysql_query("INSERT INTO example (name, age) VALUES('$name', '$age') ")
or die(mysql_error());
mysql_query("INSERT INTO example2 (name, fav_food) VALUES('$name', '$fav_food') ")
or die(mysql_error());
echo 'Added '.$name.' who is '.$age.' and loves ' .$fav_food. ' to the database.';
?>
Oh and i have mysql 5.1.36 and php 5.3.0
Thankyou