Hi
I am completely new to this area.
I have a database on a MySQL Server.
I also have a PHP form to allow me to add data to the Database.
I can read data from the database using PHP files.
When I execute the code I am getting no error messages.
Can some tell me what is wrong
<html>
<body>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "root"
mysql_select_db("mydb",$db);
$sql = "INSERT INTO employees (first,last,address,position) VALUES ('$first','$last','$address','$position')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Address:<input type="Text" name="address"><br>
Position:<input type="Text" name="position"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
} // end if
?>
</body>
</html>
I am completely new to this area.
I have a database on a MySQL Server.
I also have a PHP form to allow me to add data to the Database.
I can read data from the database using PHP files.
When I execute the code I am getting no error messages.
Can some tell me what is wrong
<html>
<body>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "root"
mysql_select_db("mydb",$db);
$sql = "INSERT INTO employees (first,last,address,position) VALUES ('$first','$last','$address','$position')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Address:<input type="Text" name="address"><br>
Position:<input type="Text" name="position"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
} // end if
?>
</body>
</html>