-
-
CommentAuthoracousticsam
- CommentTimeJul 8th 2008 edited by acousticsam on the 10th July 2008 at 17:58:49 EDT
Hi everyone,
I'm in the process of a site redesign (moving away from WordPress)... and having some trouble implementing a PHP contact form.
This site is where I got the script from: ajaxtutorial.net/index.php/ajax-contact-form/
And this is my website so far: http://samnabi.com
I can send the information to my desired email address no problem, but the sender's email address isn't there... so I don't know who to reply to!
This is what I get in my From: field... rnReply-To: rnX-Mailer: PHP/4.4.8
If anyone could help me out, that'd be awesome. I think this is where the problem lies:// SEND EMAIL TO email_to1 - message to you!!
$headers = 'From: '.$email_from1."rn" .
'Reply-To: '.$email_from1."rn" .
'X-Mailer: PHP/' . phpversion();
On a side note, my email address is not encrypted. Does anyone know how I could go about doing that? I tried replacing the characters with their ASCII codes, but that didn't work. -
-
-
CommentAuthorgnome
- CommentTimeJul 8th 2008
<?PHPThat is my email-code, minus some basic logic (bot protection, don't send with no return address or message body, etc). Does your email need to be encrypted if all the emailing is in PHP? Without me replying to an email, there is no way to get my email address from that script.
mail("MY-EMAIL-HERE", $_POST[ 'subject' ], $_POST[ 'comment' ], "From:". $_POST[ 'name' ] . "<" . $_POST[ 'email' ] . ">" );
?>
<form action="/" method="post">
<fieldset>
<p><label for="name">Name:</label></p>
<input alt="name" id="name" type="text" name="name" /><br /><br />
<p><label for="email">Email:</label></p>
<input alt="email" id="email" type="text" name="email" /><br /><br />
<p><label for="subject">Subject:</label></p>
<input alt="subject" id="subject" type="text" name="subject" /><br /><br />
<p><label for="comment">Comment:</label></p>
<textarea rows="5" cols="20" name="comment" id="comment"></textarea><br /><br />
<input class="submit" type="submit" value="submit" />
</fieldset>
</form> -
-
- CommentAuthorsquirrelnmoose
- CommentTimeJul 9th 2008
Here is a good free php script if you want a simple solution.
http://formtoemail.com/
Here's a great open source form management system http://formtools.org/
and if you want drag and drop http://wufoo.com/
I'm not sure about your issue without more code. But the above form tools are simple to configure and work as they say. -
-
CommentAuthoracousticsam
- CommentTimeJul 9th 2008 edited by acousticsam on the 09th July 2008 at 09:01:34 EDT
@gnome: Brilliant, I didn't know that the PHP is hidden from view source. I guess there's no need for encryption. I will try to use your code, and see how far I get...
Edit: gnome, does your PHP call on the name or the id of the input tags?
@squirrelnmoose: Those look like great tools, unfortunately I don't want to redirect to a thank you page (my site is a single page). And I would really like to host it myself. I was looking at Wufoo before, and it looks really easy, but I don't want to have to rely on remotely hosted stuff. -
-
- CommentAuthorfernbap
- CommentTimeJul 9th 2008 edited by fernbap on the 09th July 2008 at 09:18:27 EDT
and this is the code i'm using for simple text mails:if($_POST['text']!="" && $_POST['name']!="") {
$text=$_POST['text'];
$name=$_POST['name'];
$email=$_POST['email'];
$header="From: Yourname website@email.com \r\n";
$to="Your email \r\n";
if(mail($to,"Message from yourwebsite","message posted by".
$name." at ".$email.":\r\n".$text,$header)) $message="mail sent";
} else $message="error sending mail";
} else $message="Message empty";
Of course, you need to protect your script from malicious injections -
- CommentAuthorj4s0nn3w
- CommentTimeJul 9th 2008
Sam -
I use soupermail for my website as well as all of my clients' websites. It is easy to configure and works quite well, you can fully configure the output format in whatever fashion you like. You can find it here -
-
CommentAuthorgnome
- CommentTimeJul 9th 2008
Sam: I only use both because when I wrote that I was too lazy to look it up. I'd guess that it uses the name, if I had to guess. Unless you tell the PHP to echo something, it isn't visible to folks without FTP access, or some other kind of viewer on your website. -
-
-
CommentAuthoracousticsam
- CommentTimeJul 9th 2008 edited by acousticsam on the 09th July 2008 at 19:38:40 EDT
gnome, your code works like a charm. I just replaced 23 lines of code with your one line, and it works perfectly now.
Edit: I only have ids on my input tags, so the name attributes shouldn't be necessary.
One nitpicky question: is there any way to have some text appear before the message body (or in the subject), so that I know it's coming from my website's contact form? -
-
-
CommentAuthorgnome
- CommentTimeJul 10th 2008
replace
$_POST[ 'comment' ]
with
" ** From The Contact Form **
" . $_POST[ 'comment' ]
the newline will actually put a new line in the message body. -
-
-
CommentAuthoracousticsam
- CommentTimeJul 10th 2008
Awesome, thanks again gnome. -
1 to 10 of 10
