Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Posts
    147
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Undefined variable

    hi

    My php send mail script says after the form is submited

    "Notice: Undefined variable: message in d:\inetpub\wwwroot\cabc.co.za\testsite\sending.php on line 20
    sent "



    below is my script: why am i getting this error .. because
    I receive the mail from the form
    http://www.cabc.co.za/testsite/testform.htm

    Please can you help.

    thanks

    Andrew

    <?php // <---- you need full open tags, not short ones


    header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');



    header ('Last-Modified: '.gmdate ('D, d M Y H:i:s').' GMT');
    header ('Cache-Control: no-store, no-cache, must-revalidate');
    header ('Cache-Control: post-check=0, pre-check=0', false);
    header ('Pragma: no-cache');

    $txtTo = "andrew@hamandmushroom.co.za";
    $txtFrom = sprintf ("From: %s \r\n", $_POST['Email_Address']);
    $subject = "sub newway ";
    $header = "header new way \n\n";
    $footer = "footer new way \n";

    // continue with rest of form...
    $message .= sprintf ("Name : %s \n\n", $_POST['Name']);
    $message .= sprintf ("E-mail : %s \n\n", $_POST['Email_Address']);
    $message .= sprintf ("Address : %s \n", $_POST['Address']);

    mail ($txtTo, $subject, $header.$message.$footer, $txtFrom);
    ?>
    <html>
    <head>
    <title>Order Confirmation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    </head>
    <body>

    <!-- confermation page starts here below this...// -->

    sent
    <!-- REMEMBER to make the form send button to go to this file...// -->
    </body>
    </html>

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    It's only a notice.

    The problem is you're appending data to a variable without initially declaring that it exists.

    If you started your code with a
    Code:
    $message="";
    you should fix the problem.


  •  

    Posting Permissions

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