Click to See Complete Forum and Search --> : Adding Records!


mckintosh41
10-25-2007, 02:00 PM
im using phpadmin and i want to make a form that can add records to my database here are my html codes:

<htmL>
<body>
<form action="insert.php" method="post">
First Name: <input type="text" name="first"><br>
<input type="Submit">
</form>
</body>
</html>


and here are my php codes

<?
$username="root";
$password="";
$database="trial";

$first=$_POST['first'];


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO name VALUES ($first)";
mysql_query($query);

mysql_close();
print($first);
?>

as u can see i put print commands at the last line just to make sure it is passing the record but for some reason it doesnt add any records to my database can u pls help me.

scragar
10-25-2007, 02:28 PM
$query = "INSERT INTO TABLENAME(FIELD1) VALUES ('$first')";