Jump to content

E-mail Form


doubledee

Recommended Posts

$from = $_POST['from'];
$subject = $_POST['subject'];
$body = $_POST['body'];
$header = 'From: Website form - $from';
mail([email protected], $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([email protected], $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([email protected], $from, $subject, $body, 'From: Website form - $from');

 

 

Debbie

 

 

Link to comment
https://forums.phpfreaks.com/topic/248725-e-mail-form/#findComment-1277365
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
https://forums.phpfreaks.com/topic/248725-e-mail-form/#findComment-1277481
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
https://forums.phpfreaks.com/topic/248725-e-mail-form/#findComment-1277618
Share on other sites

Archived

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

×
×
  • 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.