Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

php variables passing issue

  • 01-11-2005 10:48PM
    #1
    Registered Users, Registered Users 2 Posts: 528 ✭✭✭


    Hi all,

    Anyone can tell me why I get an error message "Notice: Undefined variable: comments in C:\Inetpub\wwwroot\test\do.php on line 9"

    Here is the code :

    form.htm:

    <html>
    <body>
    <form action="do.php" method="post">
    username: <input type="text" name="username"><br>
    address: <input type="text" name="useraddr"><br>
    <textarea name="comments"></textarea>
    <input type="submit" value="Do">
    </form>
    </body>
    </html>

    do.php:

    <?php
    #recipient's email address
    $to = "me@yahoo.com";#here I enter my email

    #Subj
    $re ="Website Feedback";

    #message from the form
    $msg=$comments;

    #send now
    mail($to,$re,$msg);
    ?>

    <html><body>
    thanks!<br>
    </body>
    </html>


Comments

  • Registered Users, Registered Users 2 Posts: 5,333 ✭✭✭Cake Fiend


    Global vars are most likely turned off. Use the superglobal $_POST array (google it if you don't know what it is).


  • Registered Users, Registered Users 2 Posts: 528 ✭✭✭Drexl Spivey


    Bingo!

    I replace $comments with $_POST["comments"]

    Thanks! :)


Advertisement