Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

php variables passing issue

Options
  • 01-11-2005 10:48pm
    #1
    Registered Users 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 Posts: 5,335 ✭✭✭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 Posts: 528 ✭✭✭Drexl Spivey


    Bingo!

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

    Thanks! :)


Advertisement