absolute beginner-idiot needs help
Posted: Mon Feb 12, 2007 6:39 pm
feyd | Please use
obviously with username, password etc between the " "
In the body of the html i inserted this code for my form:
should this work? why isn't it? any help much appreciated.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
i'm an absolute beginner at this and i'm sure it's all very simple but i'm bangin my head against the proverbial here.
i'm creating a website for my missus but havin real trouble with the contact form. The hosting company provides us with a mysql database. i want to send the form data to the database.
above the html tags i inserted this code:Code: Select all
<?php
$db_host = "localhost";
$db_user = "";
$db_pwd = "";
$db_name = "";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
?>In the body of the html i inserted this code for my form:
Code: Select all
<?php
if (!isset($_POST['submit'])) {
?>
<form action="" method="post">
Name: <input type="text" name="name"><br>
Address 1: <input type="text" name="address1"><br>
Address 2: <input type="text" name="address2"><br>
Postcode: <input type="text" name="postcode"><br>
Telephone: <input type="text" name="telephone"><br>
Email: <input type="text" name="email"><br>
Comments: <input type="textarea" name="comments"><br>
<input type="submit" name="submit" value="Submit!">
</form>
<?php
} else {
$name = $_POST['name'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$postcode = $_POST['postcode'];
$telephone = $_POST['telephone'];
$email = $_POST['email'];
mysql_query("INSERT INTO `contact_us` (name, address1, address2, postcode, telephone, email, comments) VALUES ('$name', '$address1', '$address2','$postcode','$telephone','$email','$comments',)");
echo "Thank you, your information has been added.";
}
?>should this work? why isn't it? any help much appreciated.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]