Evo primjer koji sam nasao na youtube:
http://www.youtube.com/watch?v=X-aJ8SMcB1o&feature=related
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('could not connect: ' .mysql_error());
}
$firstname = $_post["firstname"];
$lastname = $_post["lastname"];
//echo $firstname;
//echo $lastname;
mysql_select_db("boston", $con);
mysql_query("insert into test (firstname, lastname)
values ('$firstname', '$lastname')");
?>
------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3c//dtd xhtml 1.0 Transitional//en"
"
http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Forms</title>
</head>
<body>
<form id="form1" name="update" method="post" action= "formhandler.php" >
firstname: <input type="text" name="firstname" id="textfield" />
<br/>
lastname: <input type="text" name="lastname" id="textfield2" />
<input name="" type="submit" />
</form>
</body>
</html>
Greske koje izbacuje:
Notice: Undefined variable: _post in C:\xampp\htdocs\phpacademy\tutorials\mysql\formhandler.php on line 9
Notice: Undefined variable: _post in C:\xampp\htdocs\phpacademy\tutorials\mysql\formhandler.php on line 10