WordPress Email Form Hack

WordPress Email Form Hack

UPDATE: Use Ryan Duff’s WP-ContactForm Plugin instead.

I decided not to put my contact address directly online, but my original instructions kinda sucked. So I modified the php email script at StarGeek to work for my contact page.

To make the basic form look like the rest of this site, I copied index.php as email.php and replaced everything in the content div with the contents of this text file

Instructions

Just replace with your email address, and this might work for you too. Use email.php for your email links, and this should work. The original script makes some assumptions about how sendmail is setup on your server, so you’ll need to dig into it. I’m not a PHP or linux expert, so your mileage may vary.

The CSS class might not work for IE users though unless you are applying text-align:center in a containing DIV outside of this block, or so I’m told.

Other Notes

I also was reading about a built-in email validation function at ScriptyGoddess, so I put that in too.

3 Comments

  1. brian 20 years ago

    Hey Ive been trying to get your email script to work for a while now and ive gone through it pretty well but i keep getting and error near the end and im wondering if it has to do with my particular installation of php.

    the error is this Parse error: parse error, unexpected T_VARIABLE in /home/brians6/public_html/jm/contact/contact_index.php(674) : eval()‘d code on line 2

    any idea why it might be doing that?

    i also go another errror on line 648 but i removed one set of the single quotes and it fixed but i cant seem to get around the other error.

    thanks for your help!
    ——-

  2. Dave 20 years ago

    I had that problem when I first tried to get StarGeek’s script to work, so I changed it so it worked for me. It’s also possible that the Markdown processing is converting quotes into something “not good”, so I’ve put the code into a text file now. I’m not sure what “line 2” is for your code, or what line 674 has on it, so it’s hard to diagnose beyond that.

  3. Loco Mote 20 years ago

    I’m getting the parse error: “parse error, unexpected T_ENDFOREACH in /home/cotsford/public_html/locomote/email.php on line 121” 

    Line 121 of my code for email.php is: “<?php endforeach; else: ?>”

    Any hints?  :)