Jump to content

Sending Form Data Issue


Kevin M

Recommended Posts

I'm currently working on a contact form for a client's website. It's just a basic form with name, e-mail address, and message. The data is then supposed to be sent to the client's specified e-mail address. I've got two problems. Here is my code:

<?phpif ($_GET['page'] == 'contact') {if ($_GET['contact'] == 'send') {if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) {echo '<h1>Please make sure you fill in all of the form fields.</h1>';} else {$name = strip_tags($_POST['name']);$email = strip_tags($_POST['email']);$message = strip_tags($_POST['message']);mail("e-mail@domain.com", "Subject: New Contact E-Mail","New Contact E-Mail\n$name\n$email\n$message");echo '<h1>Your data has been sent</h1>';}}}?><br /><br /><div class="top_"><h1>Contact</h1></div> <div class="center"> <div id="content"><form action="?page=contact&contact=send" method="post"><label for="name"><strong>Name:</strong></label> <input type="text" id="name" /><label for="email"><strong>E-Mail:</strong></label> <input type="text" id="email" /><label for="message"><strong>Message:</strong></label><br /><textarea rows="10" cols="30" id="message">Place your message here...</textarea><br /><input type="submit" value="Submit" id="submit" /></form><br /> </div> </div>

Problem 1) I always get the error: "Please make sure you..." even if all form fields are filled in correctly.Problem 2)If I comment out the detect for an error part, it shows me the right message, but the email is not recieved. It is being sent to a Hotmail account if that helps in Any way. So basically, it shows "Your data has been sent", but the client doesn't get an e-mail.So those are my two problems. I don't really want to share a link because it is a personal site for the client and their friends and family to use.Any help is greatly appreciated,Kevin

Link to comment
Share on other sites

Hi.. Have you seen your form's element..? In that there is no name attribute for name,email,message.. so specify name attribute for them as following:-------------------------------------------------<form action="?page=contact&contact=send" method="post" name="frmpost"><label for="name"><strong>Name:</strong></label> <input type="text" id="name" name="name"/><label for="email"><strong>E-Mail:</strong></label> <input type="text" id="email" name="email"/><label for="message"><strong>Message:</strong></label><br /><textarea rows="10" cols="30" id="message" name="message">Place your message here...</textarea><br /><input type="submit" value="Submit" id="submit" /></form>-----------------------------------------------------Regards,Vijay

Link to comment
Share on other sites

Hotmail is notorious for trashing email sent through PHP, make sure it's not going into the spam folder. Also use the headers on the email to specify a from address and maybe a reply to. You can see an example of that on the documentation page for the mail function on php.net.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...