this is my insert code <?php $con = mysql_connect("this left for security reasons"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my database", $con); $sql="INSERT INTO exchange (name, username, password, email, parkname, parkloc, caravan) VALUES ('$_POST[name]','$_POST[username]','$_POST[password]','$_POST[email]','$_post[parkname]','$_post[parkloc]','$_post[caravan]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> PHP: and this is the form <html> <body> <form action="insert.php" method="post"> name: <input type="text" name="name" /> username: <input type="text" name="username" /> password: <input type="text" name="password" /> email: <input type="text" name="email" /> park name: <input type="text" name="parkname" /> park location: <input type="text" name="parkloc" /> caravan details: <input type="text" name="caravan" /> <input type="submit" /> </form> </body> </html> HTML: this is my query code ]<?php $con = mysql_connect(""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("", $con); $result = mysql_query("SELECT * FROM exchange"); echo "<table border='1'> <tr> <th>parkname</th> <th>parkloc</th> <th>caravan </tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['parkname'] . "</td>"; echo "<td>" . $row['parkloc'] . "</td>"; echo "<td>" . $row['caravan'] . "</td>"; echo "</tr>"; } echo "</table>";mysql_close($con);]?> PHP: all that shows in the database is the first 4 fields cheers Doug
1. - php variable names are case sensitive so if you want to use $_POST superglobal write $_POST not $_post 2. mysql_close($con);]?> - remove "']" Did you ran it?
big thanks for that worked a treat one other question i ment to ask is how do i get it to move to another page after the record is add at the moment comes up with record added and stays there can i add some thing like continue then go to home page echo "1 record added";mysql_close($con)?> PHP: once again big thanks Doug
you can use header function to redirect after adding the records.you can use it in this way: header("Locationagename"); at it at the bottom of your PHP script for adding the records in DB.just modify the pagename.