Webforumz's RSS FeedRSS Webforumz RegistrationRegister Contact Webforumz StaffContact

Comment form

This is a discussion on "Comment form" within the Web Page Design section. This forum, and the thread "Comment form are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices




Reply
 
LinkBack (1) Thread Tools
  1 links from elsewhere to this Post. Click to view. #1  
Old Jul 24th, 2006, 12:52
Junior Member
Join Date: Jul 2006
Location: weymouth
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Comment form

Hi I have created a comments form in php, which is located at www.galaxywindows.co.uk/comments.php

However when i click submit the message isn't sent to my email, Does anyone know why this might be. Below is the code.

Part 1 - Comments.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
if(isset($_GET['posted'])) {
$to = 'jonbenitos@gmail.com'; //Email address to send it to
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$message = $_POST['message'];
//This is the body of the email. You can modify it...
$body = 'Name: ' . $fname . ' ' . $lname . ' Email: ' . $email . ' Message: ' . $message;
//Send the message...
if(mail($to, 'Site Message', $body)) {
die('Success!');
} else {
die('Failure!');
}
}
?>
<form method="Post" action="http://www.galaxywindows.co.uk/comments.php?posted=yes">
<table>
<tr>
<td><label for="fname">First Name:</label></td>
<td><input type="text" name="fname" /></td>
</tr>
<tr>
<td><label for="lname">Last Name:</label></td>
<td><input type="text" name="lname" /></td>
</tr>
<tr>
<td><label for="email">E-Mail:</label></td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td><label for"message">Message:</label></td>
<td><textarea name="message"></textarea></td>
</td>
<tr>
<td><input type="submit" /></td>
</tr>
</table>
</form>
</body>
</html>





Part 2 - Code.php

<?php
if(isset($_GET['posted'])) {
$to = 'jonbenitos@gmail.com';
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$message = $_POST['message'];
//This is the body of the email. You can modify it...
$body = 'Name: ' . $fname . ' ' . $lname . ' Email: ' . $email . ' Message: ' . $message;
//Send the message...
if(mail($to, 'Site Message', $body)) {
die('Success!');
} else {
die('Failure!');
}
}
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old Jul 24th, 2006, 14:24
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Comment form

There are several problems with your code.

The form method is defined as 'POST' but you have started your php checking with issset($_GET['posted']).

Remove the ?posted=yes' from your action url and give your submit button a name and a value. Both of which can be 'posted' if you like.

Your call to mail() does not include the forth variable. This can be a single thing or it can be a headers variable containing many elements that make up the header information.

At the very least it should have a 'From: ...' otherwise you risk the email getting treated like 'spam' and being filtered out.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jul 24th, 2006, 14:38
Junior Member
Join Date: Jul 2006
Location: weymouth
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Comment form

could you post me the corrected code, I would be very grateful because I'm not sure how to get it working.Thanks alot

Regards
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jul 25th, 2006, 00:16
Reputable Member
Join Date: Dec 2005
Location: U.S.A.
Posts: 155
Thanks: 0
Thanked 4 Times in 4 Posts
Re: Comment form

Maybe you should try to fix the code yourself. I doubt anyone is going to do it for you. But they will be happy to help you if you get stuck. I may be wrong but I don't understand why you have die twice in your code with one echoing success? I could be wrong but I personally have never seen that in a mail script. As far as I know die kills the script.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jul 25th, 2006, 01:06
Reputable Member
Join Date: Jul 2005
Location: Indiana, USA
Age: 29
Posts: 153
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Comment form

jonbenitos,

Here this may help: Simple Contact Form
Last Blog Entry: Whats in a name? (Feb 20th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
comment, form

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/web-page-design/7625-comment-form.htm
Posted By For Type Date
Simple Contact Form « FocusedTutorials.com This thread Refback Dec 26th, 2006 20:15

Similar Threads
Thread Thread Starter Forum Replies Last Post
Comment Box In JavaScript? kela JavaScript Forum 2 Feb 14th, 2008 09:36
how to create a comment page? kool77 Web Page Design 5 Jun 24th, 2007 09:26
Comment the Logo Superman Graphics and 3D 3 Apr 6th, 2007 19:59
Comment Box Travis R Web Page Design 2 Oct 11th, 2006 18:05
comment accessman Databases 3 Sep 19th, 2005 11:36


All times are GMT. The time now is 19:00.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8