Forum Moderators: coopster
Using PHP and MySQL, all I simply want to do is insert multiple records into the same table... but alas, being the ignorant newbie that I am, it isn't causing me much hassle.
I want the user to be able to type into multiple text fields that are then declared as variables and submitted to the database. Help?
This is my pathetic coding thus far:
[PHP]
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<p>
Type book title:<textarea name="booktitle"></textarea><br>
Type ISBN here:<textarea name="isbn"></textarea><br>
Type Author here:<textarea name="Author"></textarea><br>
Type Genre here:<textarea name="Genre"></textarea><br>
<input type="submit" name="submit" value="SUBMIT" >
</p>
</form>
<?php
if (isset($_POST['submit'])) {
$booktitle = $_POST['booktitle'];
$isbn = $_POST['isbn'];
$author = $_POST['author'];
$genre = $_POST['genre'];
$insert = "INSERT INTO Book SET
Title='$booktitle',
ISBN='$isbn',
Author='$author',
Genre='$genre';
if (@mysql_query($insert)) {
echo('Book Title has been added.<br>'); }
else {
echo('Error in submission:' . mysql_error());
}}
?>
[/PHP]
I keep getting errors everytime I play around with it. Can anyone shed any light?
[edited by: Fullest_Empty at 12:36 am (utc) on Mar. 22, 2004]