hi guys need help


#1

Is there like the simplest way of showing a guy how to send a form using PHP the form is done in dreamweaver. the form only has the following fields: name, email, telephone and comments here, and a submit button to send the data to an email
would appreciate any help, thanks :-?


#2

Hi nate,

Ok, this is bare bones, but here we go:

Firstly, create a page called form.php and put your code in for your form. Something like this:

CONTACT ME!
Name:
E-Mail:
Telephone No:
Comments:
 

Secondly, create another page and call this one formpage.php. Put this in the same directory as your above page. You`ll also need to create an error.php page and also a thanks.php page.

In the formpage.php, youll want the following code inside PHP tags. Dont include the *. Edit the 3 variables at the start.


<?*php

$youremail = "youremail@you.com";
$email_subject = "Contact";
$website = "My Website";

if ((isset($_GET['action'])) && ($_GET['action']=="send"))
{

$name = trim($_POST['name']);
$phone = trim($_POST['phone']);
$comments = trim($_POST['comments']);
$email = trim($_POST['email']);

//If you want error checking include the following:

if (($name=="") || ($phone == "") || ($comments=="") || ($email==""))
{

header("Location: error.php");

}

//Assemble message

$message = "Name: $name";
$message .= "nTelephone No: $phone";
$message .= "nComments:nn $comments";

//Send mail

mail($youremail, $email_subject, $message, "From: $website<$youremail>");

header("Location: thanks.php");

?>

There are more advanced things you can do, but this should get you started. You can for instance send a message to whoever sent the form. Its up to you.

Give it a try.

:)

#3

just read your reply now going to give it a shot will keep you posted
thanks