formmail.php help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jwaterdawg
    Senior Member
    • Aug 2005
    • 656
    • Washington, NC USA
    • JET

    #1

    formmail.php help

    Okay, so this is not at all a woodworking related question but I know some of you guys are computer geniuses so I'd rather ask here than at one of the computer forums where I wouln't be able to understand the answer.

    I need to create a form page for users of a website to submit an email. I do not want to put the email address on the page as that is just asking for spamola. I came across "formmail.php" which seems to be what I want but when I try to use it I get "HTTP 405 - Resource not allowed". Does that mean our university server is blocking that service?

    Is there another way of doing what I want? I suppose I could put jpg's of the email address on the page and ask the users to type it in but I was hoping for something a little slicker. Suggestions? And thanks for all the great help I'm sure I will get!
    Don't be stupid, the universe is watching.
  • sacherjj
    Senior Member
    • Dec 2005
    • 813
    • Indianapolis, IN, USA.
    • BT3100-1

    #2
    I just use a php page I wrote or borrowed (can't remember). Here is the functional section of it (make sure to put your email in the [PUT EMAIL ADDRESS HERE]:

    <?php

    $sSubject = "";
    $sMessage = "";
    $sEmail = "";
    $sBody = "";
    if($HTTP_POST_VARS)
    {
    $sEmail =$HTTP_POST_VARS["email"];
    $sSubject = $HTTP_POST_VARS["subject"];
    $sBody = $HTTP_POST_VARS["body"];

    if((strlen($sSubject) > 0) && (strlen($sEmail) > 0) && (strlen($sBody) > 0))
    {
    @mail("[PUT EMAIL ADDRESS HERE]","Contact Form: " . $sSubject,$sBody,"From:$sEmail");
    $sMessage = "Message Submitted Successfully";
    $sSubject = "";
    $sEmail = "";
    $sBody = "";
    }
    else
    {
    $sMessage = "Please complete all fields and try again.";
    }
    }


    ?>
    <h2>Contact Me</h2>

    <table width="<?=$sWidth?>">
    <tr><td>
    <form name="frmContact" action="contact.php" method="post">
    <p>I'm sorry to have to resort to a form to contact me, but I have already had
    too many robots scrape my site to get my email and add it onto SPAM lists. This form
    will send an email to me and I will get back to you as soon as possible.</p>

    <p>
    <b><?=$sMessage?></b>
    <br><br>
    <table>
    <tr>
    <td>Email:</td>
    <td><input type="text" name="email" value="<?=$sEmail?>" size="60"></td>
    </tr>
    <tr>
    <td>Subject:</td>
    <td><input type="text" name="subject" value="<?=$sSubject?>" size="60"></td>
    </tr>
    <tr>
    <td colspan="2">
    <textarea name="body" cols="70" rows="12"><?=$sBody?></textarea>
    </td>
    </tr>
    <tr>
    <td colspan="2"><input type="submit" value="Submit Email"></td>
    </tr>
    </table>
    </p>
    </form>

    </td></tr>
    </table>
    Joe Sacher

    Comment

    • jwaterdawg
      Senior Member
      • Aug 2005
      • 656
      • Washington, NC USA
      • JET

      #3
      Joe,

      Thanks. I have a follow up question that will reveal my complete ignorance about php.

      Do I insert the xml you sent inside the <body></body> of an htm file or what? If I do that and post it on the server the page comes back with a bunch of gobbily-goo (highly technical term I know). Basically it shows the php source and then a form.


      Can you send me a link that shows this puppy in action.

      Thanks,
      Jay
      Don't be stupid, the universe is watching.

      Comment

      • sacherjj
        Senior Member
        • Dec 2005
        • 813
        • Indianapolis, IN, USA.
        • BT3100-1

        #4
        I use this form on a few of my sites, here is one:

        http://joesacher.com/contact.php

        I removed header and footer rendering, so this might need some correction to get the HTML perfect. Basically, the top php code does nothing until the form is posted back on itself. If it gets enough after the post, it sends an email. If not, it displays a message to that effect. You should modify the HTML code near the bottom to fit your site. Feel free to post a few things through my form, to get a feel for how it works. If you get output, post the actual output from your script. It is hard to debug "gobbily-goo"

        I guess I didn't really answer your question. You should put <html><body> </body></html> around everything past the <?php ?> code.
        Last edited by sacherjj; 06-13-2006, 01:11 PM.
        Joe Sacher

        Comment

        Working...