Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7

Thread: Php Send Mail

  1. #1
    Member
    Join Date
    Jan 2004
    Posts
    68
    Member #
    4547
    I'm very new to PHP, but I want to use it to handle a one entry form I have on a site I'm making.

    The action for the submit is this to access this php file:

    PHP Code:
    <?php

    $address
    =$_REQUEST['email'];
    $message="Email Address: $address";
    $subject="Newsletter Request";

    if (isset(
    $_REQUEST['email']))
    //if "email" is filled out, send email
    {
    //send mail
    mail "myemail@mydomain.com""Subject: $subject"$message);
    echo 
    "Thank you, you will receive our next issue.";
    }
    else
    {
    echo 
    "<form type='input' action='newsletter.php' method='post' enctype='text/plain'>Interested in receiving our newletter? Email:<input type='text' name='email' /><input type='submit' value='Submit' /></form>";
    ?>
    Here is my form HTML:

    HTML Code:
    <form type="input" action="newsletter.php" method="post" enctype="text/plain">
    			Interested in receiving our newletter? Email:
    			<input type="text" name="email" />
    			<input type="submit" value="Submit" />
    </form>
    Any help would be greatly appreciated, thanks.

    Jake

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    I don't see anything immediately wrong with it, although I've also never seen the enctype used for anything other than upload forms (multipart form data).

    What's the problem you're having?
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Member
    Join Date
    Jan 2004
    Posts
    68
    Member #
    4547
    When I insert the email address and click submit, I just get a white page. That means there's an error right, the server didn't parse it or whatever.

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,733
    Member #
    5580
    Liked
    718 times
    It worked for me when I removed the "enctype" ...

    else
    {
    echo "<form type='input' action='newsletter.php' method='post'>Interested in receiving our newletter? Email:<input type='text' name='email' /><input type='submit' value='Submit' /></form>";
    }
    ?>


    But once it displays "Thank You", if you refresh the screen, it sends it again,
    because isset is isset. It might be better to redirect to another page in order
    to get out of that script. Also, this form is wide open for spammers. A little
    captcha, or answering a "human only" question might help.


  6. #5
    Member
    Join Date
    Jan 2004
    Posts
    68
    Member #
    4547
    Thank you for your help guys. Whether it was the enctype, and or the fact that the else didn't have a closing }, it's fixed now thanks.

    As for security what do you recommend? I just want the input of the email is there anything else I can do to keep the same look?

    Again, thanks for the help.

    Jake

  7. #6
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    D'oh, the } was definitely the problem. Why PHP didn't report a simple parse error, I don't know. Try adding:
    PHP Code:
    error_reporting(E_ALL); 
    ...to the beginning of the script.

    You at least something like a CAPTCHA (read this image and type its contents sort of thing).
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,733
    Member #
    5580
    Liked
    718 times
    Jake ...

    Keeping it simple with the same look and only the email field?
    Not much you can do about spammers. Perhaps it won't be
    a problem ... it all depends on how popular the site is, and how
    many visits you get.



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:26 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com