Jump to content

Trouble with e-mail form


CapellaM44

Recommended Posts

I am extremely new to programming. I got thrown into the position of running our club's web page (long story) I managed to recreate a web page that is a lot more user friendly than the old site thanks to the help from this site. However, there is one thing I can't get right. That is the form page.

 

Our host is "hostgator.com" and they have a short bit of code on their page I tried to use, but was unsuccessful. I kept receiving an error saying "e-mail address cannot contain (,)<> ect. I have checked and double checked the code and e-mail, but I can't seems o make anything work.

 

When I use the code provided in the "PHP Secure E-mail" section on this site, I can click submit, but get a 404 error. I don't seem to be able to find a way to redirect the e-mail back to the main site so I do not receive this error. I am creating the form in text, and uploading it to a test folder on the site so I can see how it works over the net.

 

Is there someone here who may be able to help me get a form up and running?

 

Thanks

Link to comment
Share on other sites

If possible, I would like to add a drop down menu as to the nature of the e-mail. Example is Business, rental, entertainment, ect. Not necessary, but nice. Below is the basic code I copied from this site and "modified" to add a couple extra fields to suit our needs.
<html>
<body>
<?php
function spamcheck($field) {
// Sanitize e-mail address
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
// Validate e-mail address
if(filter_var($field, FILTER_VALIDATE_EMAIL)) {
return TRUE;
} else {
return FALSE;
}
}
?>
<h2>T.E.V. Edelweiss Feedback Form</h2>
<?php
// display form if user has not clicked submit
if (!isset($_POST["submit"])) {
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>
Your E-mail: <input type="text" name="Your E-Mauk"><br>
Your Name <input type="text" name="Your Name"><br>
Your Phone Number: <input type="text" name="Your Phone Number"><br>
Best way to reach you: <input type="text" name="Best way to reach you:"><br>
Subject: <input type="text" name="subject"><br>
Message: <textarea rows="10" cols="40" name="message"></textarea><br>
<input type="submit" name="submit" value="Submit Feedback">
</form>
<?php
} else { // the user has submitted the form
// Check if the "from" input field is filled out
if (isset($_POST["from"])) {
// Check if "from" email address is valid
$mailcheck = spamcheck($_POST["from"]);
if ($mailcheck==FALSE) {
echo "Invalid input";
} else {
$from = $_POST["from"]; // sender
$subject = $_POST["subject"];
$message = $_POST["message"];
// message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// send mail
mail("use_contact_form@tevedelweiss.org",$subject,$message,"From: $fromn");
echo "Thank you for sending us feedback";
}
}
}
?>
</body>
</html>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...