Help - Search - Members - Calendar
Full Version: I Need Help With Forms.
Zymic Webmaster Forums > Zymic Free Web Hosting > Zymic Free Web Hosting - General Discussion & Help
littleSOUTHofSANITY
I haven't done this in a long while, so I'm hoping I can get some help with the problem I'm having with this form. It's supposed to be simple...I want the viewer to type in 3 pieces of info and push the submit button and have it sent to an email address. Here is what I have...

the form:
CODE
<form action="email.php" method="post">
Name: <input type="text" name="name" size="60"><br><br>
E-mail Address: <input type="text" name="addy" size="60"><br><br>
Birthday: <input type="text" name="bday" size="60"><br><br>
<input type="submit" value="Sign Me Up!"></input>
</form>


email.php:
CODE
<?php
$to = "email@email.com";
$subject = "FORM";
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers);
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>


right now (just in testing) when I submit it goes to a blank page...and no email

any help would be great!! biggrin.gif
WillieBee
Hi there

Sorry I can not help, but I am also a newbiw having logged on today

This seems a brilliant site

I have been trying to learn html, css etc but have just started to look into the use of forms, so await replies to your posting. previously I thought I wouldn't need them, soskipped that chapter on each book I read. Now I thinb I need it. The input side seems straightforward, although not easy at all,but what I'm not sure about is how the data is sorted.

Initially I just want to have data / reports sent to me via email.

My first site, just a bit of fun for the family is already live .. at www.williebee.co.uk but now I want to get on to the more serious stuff.

Regards !
DroNix
to be able to use the mail funciton, you'll have to pay a one-time fee of $10 USD. For further instructions log into the live chat.
Ed
In addition to what Dronix has said, your script is insecure too, before passing anything in as a header check its contents!

A simple fix for your script:

CODE
<?php
$to = "email@email.com";
$subject = "FORM";
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];

if(!filter_var($email, FILTER_VALIDATE_EMAIL))
   die('Invalid email address.');

$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers);

if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>


Without checking, your form can be used to send spam and land you in a lot of hot water.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.