Hello everybody
i am wondering if someone could help me with this problem i am having.
i am trying to insert some data from a web interface into the database but i am getting an error "error adding name to database".
below i have copy the code:
FORM
<?php
$mytest=mysql_connect("localhost","root","");
if (!$mytest)
{
exit("Connection Failed: " . $mytest);
}
echo'<form method="get" action="AddStudentTest.php">
<input type="text" name="Firstname">
<input type="text" name="Surname">
<input type="submit" name="AddStudentTest" value="Submit">
</form>';
mysql_close($mytest);
echo "</table>";
?>
AND THE INSERT CODE
<?php
$mytest=mysql_connect("localhost","root","");
if (!$mytest)
{
echo("Connection Failed: " . $mytest);
exit();
}
if(!mysql_select_db("test"))
{
echo "I cant connect to that db";
exit;
}
else
//$sql="INSERT INTO studenttest values('$Firstname','$Surname')";
mysql_query("insert into studenttest('Firstname') values('$Firstname')");
echo $Firstname;
if (mysql_query ($sql))
{
echo("<p>Your Name has been added.<p>");
} else
{
echo("Error adding name to database.");
}
mysql_close($mytest);
echo"</body>";
echo"</html>";
?>