Bookmark Posted July 5, 2007 Share Posted July 5, 2007 Hi All, I've only just started using forms in web design and i'm trying to create a contact us form with the options: Name :- [Form] Email Address:- [Form] Comment:- [form] ----------------------------------------- So in the contactus.php page i have the following script:- <form method="post" action="contact_form_response.php"> Name:-<br /><input name="name" type="text" size="25"><br /> Email:-<br /><input name="email" type"text" size="25"><br /> Message:-<br /> <textarea name="message" cols="50" rows="2"></textarea> <br /><input type="submit" name="submit_button" value="submit"> </form> ----------------------------------------- But I dont understand what php coding I have to put in the file contact_form_response.php ----------------------------------------- Thanks, Quote Link to comment Share on other sites More sharing options...
trq Posted July 5, 2007 Share Posted July 5, 2007 What do you want to happen? An email? Look at the mail function and examples. Quote Link to comment Share on other sites More sharing options...
Bookmark Posted July 5, 2007 Author Share Posted July 5, 2007 So an email would be sent when you click the "submit" button. Quote Link to comment Share on other sites More sharing options...
trq Posted July 5, 2007 Share Posted July 5, 2007 Look at the link I posted. Quote Link to comment Share on other sites More sharing options...
Bookmark Posted July 5, 2007 Author Share Posted July 5, 2007 Right, thanks for the help so far BUT, i'm getting an error somewhere. -------------------------------------- file - contactus.php -------------------------------------- <form method="post" action="contact_form_response.php"> Name:-<br /> <input name="name" type="text" size="25"><br /> Email:-<br /><input name="email" type"text" size="25"><br /> Message:-<br /> <textarea name="message" cols="50" rows="2"></textarea> <br /><input type="submit" name="submit_button" value="submit"> </form> -------------------------------------- file - contact_form_response.php -------------------------------------- <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; //Validation if (3 < strlen($name) && 3 < strlen($email) && 3 < strlen($message)) { $email_message = <<< EMAIL Message from websites contact form. Name: $Name Email: $Email The Message: $message EMAIL; $headers ="cc:you@youralternativeaddress.com\r\n"; if(mail('xxxxxxxxxxxxxx@hotmail.co.uk','Contact Form email',$email_message, $headers)) { echo "Your email has been delivered, we will contact you shortly." } else { echo "We had a problem sending the email."; } ?> -------------------------------------- The above is the code for both files, can anybody see an error in there, so when you fill out the contact us page it will send (via the submit button) to the hotmail account. -------------------------------------- Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted July 5, 2007 Share Posted July 5, 2007 What error are you getting? Quote Link to comment Share on other sites More sharing options...
NArc0t1c Posted July 5, 2007 Share Posted July 5, 2007 What is the error message? But here's some advice: Do Not use hotmail or yahoo for these things. Quote Link to comment Share on other sites More sharing options...
Bookmark Posted July 5, 2007 Author Share Posted July 5, 2007 Basically when you hit "submit" it goes to a blank screen. Quote Link to comment Share on other sites More sharing options...
Bookmark Posted July 5, 2007 Author Share Posted July 5, 2007 This is the link for the website: http://www.codefarm.co.uk/fevnetrovers/contact_form.php (p.s only about 40% completed) Quote Link to comment Share on other sites More sharing options...
trq Posted July 5, 2007 Share Posted July 5, 2007 Put this at the top of contact_form_response.php. <?php error_reporting(E_ALL) ; ini_set("display_errors","1"); ?> Quote Link to comment Share on other sites More sharing options...
Bookmark Posted July 5, 2007 Author Share Posted July 5, 2007 ??? This is very puzzling, its displaying a blank screen still. Thanks for your help so far. Quote Link to comment Share on other sites More sharing options...
cluce Posted July 5, 2007 Share Posted July 5, 2007 I usually start out with somehting simple than I build on that. try this. I have the exact same form as you on my website and I am using this code. Just add in the error checking. This will only send an email message to you not the person filling it out. <?php $to = "you@youralternativeaddress.com"; $subject = "Contact form"; $body = " \n\n Name: $name \n\n E-Mail Address: $email \n\n Message: $message"; mail ($to, $subject, $body); header("Location: http://youralternativeaddress.com/thankyou.html"); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.