Results 1 to 8 of 8

Thread: Beginner Help

  1. #1
    Join Date
    Apr 2005
    Posts
    49
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Beginner Help

    I am wanting to learn php and have done a very small piece of script and html which I have read in a book.

    Problem is that it goes through the process and I get to see the thankyou page, but I dont receive any email.

    Please can you tell what is wrong so that I can understand what i did wrong.

    My server is able to use php.

    Thanks in advance


    html page code >
    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Email</title>
    </head>

    <body>
    <form method="post" action="sendmail.php">
    Email: <input name="email" type="text" /><br />
    Message:<br />
    <textarea name="message" rows="15" cols="40">
    </textarea><br />
    <input type="submit" />
    </form>
    </body>

    </html>

    php page code >

    <?
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;

    mail( "graham.peach@ntlworld.com", "Feedback Form Results",
    $message, "From: $email" );
    header( "Location: thank_you.html" );
    ?>

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    For a start, you need to terminate the extra headers with \r\n\r\n (double CRLF). Secondly, you need to check that your mail section is set up correctly in php.ini. This involves specifying a path for sendmail on *n?x, or an external SMTP server and address on Windows.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2005
    Posts
    49
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Sorry I dont understand

    I thought that when php is on the server thats it. wouldnt php.ini be on the server?

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yes. Under *n?x it'll be in /etc, /etc/php, or other similar locations depending on your distribution.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Apr 2005
    Posts
    49
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    ok thanks

    I have read a faq on my site and it says that all the php scripts should end in .php which it does

    and i should add this line of code

    ini_set("sendmail_from", " email@mydomain ");

    although it doesnt say where it should go

    Any ideas?
    Last edited by QuizToon; 03-23-2006 at 11:01 PM.

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well... the main problem I see above is that you should make the variables work... they're just part of the quotes now.

    look:
    "From: $email" --> From: $email
    "From: ".$email --> From: some@one.com

    this may not be the only problem, but it'll help you.

    If you don't get the above, then here....
    basically, you can continue a thing that's in quotes after ending the quote by putting a dot.
    Like this:
    PHP Code:
    $var "something".$othervar."somethingelse"."andmore".$var3.$var4
    That'll help you out a lot and let you do more complex syntax later on.

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Wrong, I'm afraid. In PHP, variables inside double quotes are parsed.
    Code:
    $hello = "Hi";
    echo('$hello'); // $hello
    echo("$hello"); // Hi
    QuizToon: There are many other directives to set than just sendmail_from. I suggest you actually use the INI file (which contains explanatory comments) rather than ini_set().
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Dang. I had it backwards. My bad.

    But... still... take note of that syntax for other stuff... it might be helpful.

    thanks for catching that twey.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •