Re: How do I create a textbox that stores values in a database?
your HTML :
<FORM action="test.php" method="post">
<INPUT type="text" value="this is a text" name"txtInput" id="txtInput" />
</FORM>
then in your test.php
<?php
// if the method="get" then you have to change to $_GET
extract($_POST);
print($txtInput); // print your text value
$db = mysql_connect("localhost", "root", "123");
mysql_select_db("mydb", $db) or die(mysql_errno() . ": " . mysql_error() . "<br>");
$sql = " INSERT INTO test VALUES('$txtInput') ";
$result = mysql_query($sql, $db);
if(!$result){
echo mysql_error();
exit;
}
// close the connection
mysql_free_result($result);
mysql_close();
?>
Last edited by welstein : 04-02-2006 at 09:23 AM.
|