Hi, Jerry,
Here's your simplified form:
----
<form action="addcontacts.php" method="post">
<input name="firstName" type="text">
<input name="lastName" type="text">
<input name="email" type="text">
</form>
----
Here is the page "addcontacts.php":
----
<html>
<body>
<?
if ($REQUEST_METHOD == "POST") {
$usr = "username for db";
$pwd = "db password";
$db = "db name";
$host = "db host (localhost, perhaps?)";
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
// NOTE that form fields automatically become variables
$sql = "insert into contacts (first name column,last name
column, email column) values ($firstName, $lastName, $email)";
mysql_query("$sql");
echo("Data Inserted.");
}
else {echo("Nothing Happened.");}
?>
</body>
</html>
----
It would be a good idea too, of course, to add some error-checking in there.
Plenty of documentation on that stuff at http://php.net .
Good luck!
Jed
On the threshold of genius, JeRRy wrote:
> Hi,
>
> I am trying to setup a PHP form to send to mySQL
> database. I know how to connect to mySQL but need
> help getting the information in the form to update
> into the mySQL database.
>
> I have the following table called contacts, I'd like
> the form to have the following fields.
>
> firstName
> lastName
> email
>
> I have created the table in my database but now need
> the code(s) to put in my PHP page for the form than
> once submit is clicked the table in my database will
> be updated. I'm too familiar with ASP and just
> started using PHP not long ago, so if anyone can help
> please let me know. I have tried some online
> resources but I continue to get errors so think I am
> doing something wrong. So I thought I'd post here so
> my question can be answered.
>
> Thankyou!
>
> http://digital.yahoo.com.au - Yahoo! Digital How To
> - Get the best out of your PC!
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php