Eksempel på database-input
Jeg har her et eksempel på princippet for input til min database.Men det virker ikke.
<HTML>
<?php
if($submit)
{
$db = mysql_connect("localhost", "root","");
mysql_select_db("learndb",$db);
$first=$_POST[first];
$last=$_POST[last];
$sql = "INSERT INTO mintabel (firstname, lastname) VALUES('$first', '$last')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
}
else
{
?>
<form method="post" action="input.php">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
<input type="Submit" name="submit" value=" Enter information"></form>
<?
}
?>
</HTML>
Hvad kan fejlen være?
