Jump to content

E-mail Form


doubledee

Recommended Posts

Okay, really dumb question...

 

If I want to make an HTML Form that is really an E-mail Form so that visitors on my website can e-mail me, how do I do that?

 

(I had read in a book last year that if you use an HTML Form, you can reduce/eliminate spam?!)

 

 

 

Debbie

 

 

Link to comment
Share on other sites

$from = $_POST['from'];
$subject = $_POST['subject'];
$body = $_POST['body'];
$header = 'From: Website form - $from';
mail(your@email.com, $from, $subject, $body, $header);

 

There.

 

I'm not sure what to do with this code?

 

Don't I need to create an HTML Form?

 

How does this code work with the Form?

 

 

--------

Also...

 

$header = 'From: Website form - $from';

 

Why do you add in "Website form - "??

 

What does that do?

 

Doesn't that break things?

 

 

mail(your@email.com, $from, $subject, $body, $header);

 

Can't spammers see my e-mail in the line above?

 

I'm totally not understanding how you are daisy-chaining things together.  As your code above stands, you would have this...

 

;
mail(your@email.com, $from, $subject, $body, 'From: Website form - $from');

 

 

Debbie

 

 

Link to comment
Share on other sites

An email form is simply a normal HTML form.  On the back end, you simply take the $_POST data, validate/filter it like normal, and then put it into the mail function.  An HTML email form, by itself, won't do much to eliminate spam.  If that's your worry, you'd need to implement some sort of CAPTCHA as well (Google search result for "PHP CAPTCHA" ).

Link to comment
Share on other sites

You all good?

 

Well, you didn't answer all of my questions...

 

So, here is what I have so far...

// Check for Data-Entry Errors.
if (empty($errors)){
	// Form data clean.

	// E-mail Inquiry to Administrator.
	$to = 'debbie@mail.com';
	$subject = $trimmed['subject'];
	$inquiry = $trimmed['inquiry'];
	$from = $trimmed['senderEmail'];
//			$headers = $from;
	mail($to, $subject, $inquiry);
//			mail($to, $subject, $inquiry, $headers);
}

 

Notice, I have been told that if you take out the ampersand and dot that most spambots won't be able to detect your text as an e-mail addy...

 

Is that true?

 

 

Debbie

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.