A
Anonymous
Guest
First you should review your MySQL book to see how you would make your changes using only MySQL. Then it becomes simple in PHP. All you have to do is create a simple HTML form using POST as the method like so...
Then make a second file called "submit.php" with a php script like this
I didn't test that, but it looks right. It's close anyways. Give it a try!
Cheers!
Justin
Code:
<HTML>
<HEADER>
</HEADER>
<BODY>
<FORM Method="post" action="submit.php">
<H1>
Input something
</H1>
<input type="text" name="something" size=30 maxlength=40>
<input type="submit" name="submit" value="add something">
</BODY>
</HTML>
Then make a second file called "submit.php" with a php script like this
Code:
<?php
//connect to mysql
$conn = mysql_connect('localhost', 'root', '');
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
//select the database
mysql_select_db("testDB",$conn);
// create the SQL statement note that the first '' in the () are for an autoincrementing id in testTable
$sql = "INSERT INTO testTable values ('', '$_POST[something]')";
// execute the SQL statement
if (mysql_query($sql, $conn)) {
echo "record added!";
} else {
echo "something went wrong";
}
?>
I didn't test that, but it looks right. It's close anyways. Give it a try!
Cheers!
Justin