iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > HTML, XHTML and CSS

Reply
 
LinkBack (1) Thread Tools
Old July 24th, 2006, 07:52 AM   1 links from elsewhere to this Post. Click to view. #1
New Member
 

Join Date: Jul 2006
Location: weymouth
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 jonbenitos is on a distinguished road
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!');
}
}
?>
jonbenitos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old July 24th, 2006, 09:24 AM   #2
Most Reputable Member
 

Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,307
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ukgeoff has a spectacular aura about ukgeoff has a spectacular aura about
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.
ukgeoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old July 24th, 2006, 09:38 AM   #3
New Member
 

Join Date: Jul 2006
Location: weymouth
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 jonbenitos is on a distinguished road
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
jonbenitos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old July 24th, 2006, 07:16 PM   #4
Reputable Member
 

Join Date: Dec 2005
Location: U.S.A.
Posts: 156
Thanks: 0
Thanked 4 Times in 4 Posts
Rep Altering Power: 0 ScottR is on a distinguished road
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.
ScottR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old July 24th, 2006, 08:06 PM   #5
Reputable Member
 

Join Date: Jul 2005
Location: Indiana, USA
Age: 30
Posts: 150
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 jpmitchell will become famous soon enough
Re: Comment form

jonbenitos,

Here this may help: Simple Contact Form
jpmitchell is offline  
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

Bookmarks

Tags
comment , form


LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/html-xhtml-and-css/7625-comment-form.htm
Posted By For Type Date
Simple Contact Form « FocusedTutorials.com This thread Refback December 26th, 2006 03:15 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Comment Box In JavaScript? kela JavaScript 2 February 14th, 2008 04:36 AM
how to create a comment page? kool77 HTML, XHTML and CSS 5 June 24th, 2007 04:26 AM
Comment the Logo Superman Graphic Specifics 3 April 6th, 2007 02:59 PM
Comment Box Travis R HTML, XHTML and CSS 2 October 11th, 2006 01:05 PM
comment accessman Databases 3 September 19th, 2005 06:36 AM


Search Engine Optimization by vBSEO 3.2.0 RC8