Forum Moderators: open
What is the best way to make a simple form?
ie, name, howd you find us, comments.
And have the info emailed to myself?
I tried doing this in frontpage and its a pain in the ass, Id rather just hand code this part.
any of these can send mail
since i know you have PHP,
take a look at
PHP's Mail Functions [php.net]
AND/OR
a tutorial
A Feedback form [thesitewizard.com]
AND/OR
look at mail scripts like this
FormMail [dtheatre.com]
I think this still working but need the visitor to use his/her email program to send the form result. here is the code.
<form method = post action = "mailto:youremailad@ip.com">
if won't work remove the?subject:'Just simple form'
this will work, but need to use the client email
If you need some help with FrontPage forms, we have a WYSIWYG Editors Forum [webmasterworld.com] where the best Front Page discussions are held.
[edited by: tedster at 9:19 pm (utc) on June 27, 2004]
If the form looks alright online, and it seems to take your input but you never get the email -- then make sure there are no typos in your e-mail address in the Front Page "Form Properties" dialog box.
If you published the page to the server, but when you look at with your browser you see a line that says [FrontPage Save Results Component], then it's time to call support at your Web hosting company.
<?php
$receiverMail= "you@example.com";
$name= ltrim(rtrim(strip_tags(stripslashes($_POST['name']))));
$email= ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
$subject= ltrim(rtrim(strip_tags(stripslashes($_POST['subject']))));
$msg= ltrim(rtrim(strip_tags($_POST['msg'])));
$ip= getenv("REMOTE_ADDR");
$msgformat= "From: $name ($ip)\nEmail: $email\n\n$msg";
if(empty($name) ¦¦ empty($email) ¦¦ empty($subject) ¦¦ empty($msg)) {
echo "<h3>the email failed</h3><p>Please fill all the fields</p>";
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo "<h3>The email was not sent</h3><p>The email address is incorect</p>";
}
else {
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
echo "<h3>Your email has been sent!</h3><p>someone from us will get back to you as soon as possible.</p>"; }
?>
save this as something like mail.php
you will then need to create a form to call mail.php ...
<form method="post" action="path/to/mail.php">
Name:<br /><input name="name" type="text" size="40" maxlength="40" /><br /><br />
Email:<br /><input name="email" type="text" size="40" maxlength="40" /><br /><br />
Subject:<br /><input name="subject" type="text" size="40" maxlength="40" /><br /><br />
Message:<br /><textarea name="msg" cols="60" rows="10"></textarea><br /><br />
<input type="reset" value="Reset" /> <input type="submit" value="Send" />
</form>
You need to set your email address in mail.php to point to the correct location. You also need to alter the form to point to the php script.
Hope this is of some help.
Mack.
Mack.
Also note... the script will not work until you upload it to your host. This is because it requires a server environment to run (php installed). The script would only work on your machine if you have a server installed (apache/iis) and php.
I think also you may have picked up some of my post wrong. The first piece of code is the script. Save it as mail.php the second section of code is the html you paste into your web page.
Mack.
this code adds the form to the same page so you won't have to make seperate pages
[pre]<?php
$receiverMail= "[b]you@example.com[/b]"; if($_POST['name'] && $_POST['email'] && $_POST['subject'] && $_POST['msg']){
$name= ltrim(rtrim(strip_tags(stripslashes($_POST['name']))));
$email= ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
$subject= ltrim(rtrim(strip_tags(stripslashes($_POST['subject']))));
$msg= ltrim(rtrim(strip_tags($_POST['msg'])));
$ip= getenv("REMOTE_ADDR");
$msgformat= "From: $name ($ip)\nEmail: $email\n\n$msg";
if(empty($name) ¦¦ empty($email) ¦¦ empty($subject) ¦¦ empty($msg)) {
echo "<h3>the email failed</h3><p>Please fill all the fields</p>";
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo "<h3>The email was not sent</h3><p>The email address is incorect</p>";
}
else {
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
echo "<h3>Your email has been sent!</h3><p>someone from us will get back to you as soon as possible.</p>"; }
} else {
echo '<form method="post" action="'.$PHP_SELF.'">
Name:<br /><input name="name" type="text" size="40" maxlength="40" /><br /><br />
Email:<br /><input name="email" type="text" size="40" maxlength="40" /><br /><br />
Subject:<br /><input name="subject" type="text" size="40" maxlength="40" /><br /><br />
Message:<br /><textarea name="msg" cols="60" rows="10"></textarea><br /><br />
<input type="reset" value="Reset" /> <input type="submit" value="Send" />
</form>';
}
?>[/pre]