need help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerry Polyak

    need help

    Can someone give me a pointer, please.

    I am getting the following errors:


    Notice: Undefined index: sender_name in c:\program files\apache
    group\apache\ht docs\allinone_f orm.php on line 12

    Notice: Undefined index: sender_email in c:\program files\apache
    group\apache\ht docs\allinone_f orm.php on line 14

    Notice: Undefined index: message in c:\program files\apache
    group\apache\ht docs\allinone_f orm.php on line 16

    Notice: Undefined index: op in c:\program files\apache
    group\apache\ht docs\allinone_f orm.php on line 24

    Here is my script:

    <html>
    <head>
    <title>All-In-One Feedback Form</title>
    </head>

    <body>

    <?
    $form_block = "
    <form method=\"POST\" ACTION=\"$_SERV ER[PHP_SELF]\">
    <p><strong>Yo ur Name:<br>
    <input type=\"text\" name=\"sender_n ame\" value=\"$_POST[sender_name]\"
    size=30></p>
    <p><strong>Yo ur Email Address:<br>
    <input type=\"text\" name=\"sender_e mail\" value=\"$_POST[sender_email]\"
    size=30></p>
    <p><strong>Mess age:</strong><br>
    <textarea name=\"message\ " cols=50 rows=5 wrap=virtual>$_ POST[message]
    </textarea></p>
    <input name=\"op\" type=\"hidden\" value=\"ds\">
    <p><input type=\"submit\" name=\"submit\" value\"Send This Form\"></p>
    </form>";

    $send = "yes";

    if ($_POST["op"] !="ds") {

    //they need to see the form
    echo "$form_bloc k";
    }
    else if ($_POST["op"] == "ds") {
    if ($_POST["sender_nam e"] == ""){
    $name_err = "<font color=red>Pleas e enter your name!</font><br>";
    $send = "no";}
    else if ($_POST["sender_nam e"] != "")
    {$name_err = "";}
    if ($_POST["sender_ema il"] == "")
    {$email_err = "<font color=red>Pleas e enter your email
    address!</font><br>";
    $send = "no";}
    else if ($_POST["sender_ema il"] != "")
    {$email_err = "";}
    if ($_POST["message"] == "")
    {$message_err = "<font color=red>Pleas e enter a message!</font><br>";
    $send = "no";}
    else if ($_POST["message"] != "")
    {$message_err = "";}

    if ($send != "no")
    {
    // it's ok to send!!
    $to = "me@me.net" ;
    $subject = "All-in-one Web Site Feedback";
    $mailheaders = "From: My Web Site <> \n";
    $mailheaders .= "Reply-To: $_POST[sender_email]\n\n";

    $msg = "E-MAIL SEND FROM WWW SITE\n";
    $msg .= "Sender's Name: $_POST[sender_name]\n";
    $msg .= "Sender's E-mail: $_POST[sender_email]\n";
    $msg .= "Message: $_POST[message]\n\n";

    mail($to, $subject, $msg, $mailheaders);

    echo "<p>Mail has been sent!</p>";
    }
    else if ($send == "no")
    {
    echo "$name_err" ;
    echo "$email_err ";
    echo "$message_e rr";
    echo "$form_bloc k";
    }
    }
    ?>
    </body>
    </html>


  • Garp

    #2
    Re: need help


    "Jerry Polyak" <jerrypolyak@NO SPAM_yahoo.com> wrote in message
    news:FO-dnRHmFMZUeeHd4p 2dnA@adelphia.c om...[color=blue]
    > Can someone give me a pointer, please.
    >
    > I am getting the following errors:
    >
    >
    > Notice: Undefined index: sender_name in c:\program files\apache
    > group\apache\ht docs\allinone_f orm.php on line 12
    >
    > Notice: Undefined index: sender_email in c:\program files\apache
    > group\apache\ht docs\allinone_f orm.php on line 14
    >
    > Notice: Undefined index: message in c:\program files\apache
    > group\apache\ht docs\allinone_f orm.php on line 16
    >
    > Notice: Undefined index: op in c:\program files\apache
    > group\apache\ht docs\allinone_f orm.php on line 24
    >
    > Here is my script:
    >[/color]
    <snip>

    It's fine, your errors are really warnings as a result of the first run of
    the script not having anything in the $_POST variable to use as value=
    attributes; presumably you've put them there because you want to repost the
    same data if there's an error.

    You could code round it, but it's easier to just put
    error_reporting (E_ERROR);
    at the top once you're satisfied that it works to your satisfaction. Or,
    like me, even change the default in php.ini so that E_ERROR is usual and put
    error_reporting (E_ALL); at the top of scripts that you're debugging.

    HTH
    Garp


    Comment

    • Jerry Polyak

      #3
      Re: need help


      "Garp" <garp7@no7.blue yonder.co.uk> wrote in message
      news:TE5fc.3163 $c65.30009465@n ews-text.cableinet. net...[color=blue]
      >
      > "Jerry Polyak" <jerrypolyak@NO SPAM_yahoo.com> wrote in message
      > news:FO-dnRHmFMZUeeHd4p 2dnA@adelphia.c om...[color=green]
      > > Can someone give me a pointer, please.
      > >
      > > I am getting the following errors:
      > >
      > >
      > > Notice: Undefined index: sender_name in c:\program files\apache
      > > group\apache\ht docs\allinone_f orm.php on line 12
      > >
      > > Notice: Undefined index: sender_email in c:\program files\apache
      > > group\apache\ht docs\allinone_f orm.php on line 14
      > >
      > > Notice: Undefined index: message in c:\program files\apache
      > > group\apache\ht docs\allinone_f orm.php on line 16
      > >
      > > Notice: Undefined index: op in c:\program files\apache
      > > group\apache\ht docs\allinone_f orm.php on line 24
      > >
      > > Here is my script:
      > >[/color]
      > <snip>
      >
      > It's fine, your errors are really warnings as a result of the first run of
      > the script not having anything in the $_POST variable to use as value=
      > attributes; presumably you've put them there because you want to repost[/color]
      the[color=blue]
      > same data if there's an error.
      >
      > You could code round it, but it's easier to just put
      > error_reporting (E_ERROR);
      > at the top once you're satisfied that it works to your satisfaction. Or,
      > like me, even change the default in php.ini so that E_ERROR is usual and[/color]
      put[color=blue]
      > error_reporting (E_ALL); at the top of scripts that you're debugging.
      >
      > HTH
      > Garp
      >
      >[/color]

      Excellent, thank you.

      I figured that is what the problem is (nothing to use for value), but had no
      idea of the workaround. Kind of new to PHP.

      Thanks again.


      Comment

      • Markus Ernst

        #4
        Re: need help

        "Garp" <garp7@no7.blue yonder.co.uk> schrieb im Newsbeitrag
        news:TE5fc.3163 $c65.30009465@n ews-text.cableinet. net...[color=blue]
        >
        >
        > It's fine, your errors are really warnings as a result of the first run of
        > the script not having anything in the $_POST variable to use as value=
        > attributes; presumably you've put them there because you want to repost[/color]
        the[color=blue]
        > same data if there's an error.
        >
        > You could code round it, but it's easier to just put
        > error_reporting (E_ERROR);
        > at the top once you're satisfied that it works to your satisfaction. Or,
        > like me, even change the default in php.ini so that E_ERROR is usual and[/color]
        put[color=blue]
        > error_reporting (E_ALL); at the top of scripts that you're debugging.[/color]

        Killing notices IMO is not debugging, but rather bugging! You can disable
        the notice reporting _after_ debugging on going online, to prevent notices
        from being displayed to the public, but they are essential for debugging.

        For a quick solution, just fill the variables before you display the form:

        if(isset($_POST['sender_name'])) $sender_name=$_ POST['sender_name'];
        else $sender_name="" ;

        .... and so on. After that you just use $sender_name. Also note the 'quotes'
        inside the ['brackets'].

        A better solution would be to display the form at the end of the code flow.
        So you can handle all your variable checking, then display a thank you
        message if all is ok or display the form again with the messages and the
        entries if it has to be resubmitted.

        HTH
        Markus


        Comment

        • Garp

          #5
          Re: need help


          "Markus Ernst" <derernst@NO#SP #AMgmx.ch> wrote in message
          news:407cf07f$0 $3738$afc38c87@ news.easynet.ch ...[color=blue]
          > "Garp" <garp7@no7.blue yonder.co.uk> schrieb im Newsbeitrag
          > news:TE5fc.3163 $c65.30009465@n ews-text.cableinet. net...[color=green]
          > >
          > >
          > > It's fine, your errors are really warnings as a result of the first run[/color][/color]
          of[color=blue][color=green]
          > > the script not having anything in the $_POST variable to use as value=
          > > attributes; presumably you've put them there because you want to repost[/color]
          > the[color=green]
          > > same data if there's an error.
          > >
          > > You could code round it, but it's easier to just put
          > > error_reporting (E_ERROR);
          > > at the top once you're satisfied that it works to your satisfaction. Or,
          > > like me, even change the default in php.ini so that E_ERROR is usual and[/color]
          > put[color=green]
          > > error_reporting (E_ALL); at the top of scripts that you're debugging.[/color]
          >
          > Killing notices IMO is not debugging, but rather bugging! You can disable
          > the notice reporting _after_ debugging on going online, to prevent notices
          > from being displayed to the public, but they are essential for debugging.[/color]

          Isn't that what I said? I use E_ALL while debugging, then remove it and keep
          warnings hidden while keeping actual errors visible? I was in a hurry, maybe
          I phrased it badly.
          [color=blue]
          >
          > For a quick solution, just fill the variables before you display the form:
          >
          > if(isset($_POST['sender_name'])) $sender_name=$_ POST['sender_name'];
          > else $sender_name="" ;
          >
          > ... and so on. After that you just use $sender_name. Also note the[/color]
          'quotes'[color=blue]
          > inside the ['brackets'].
          >
          > A better solution would be to display the form at the end of the code[/color]
          flow.[color=blue]
          > So you can handle all your variable checking, then display a thank you
          > message if all is ok or display the form again with the messages and the
          > entries if it has to be resubmitted.[/color]

          So like I said, you could code round it...

          Garp


          Comment

          • Jerry Polyak

            #6
            Re: need help


            "Markus Ernst" <derernst@NO#SP #AMgmx.ch> wrote in message
            news:407cf07f$0 $3738$afc38c87@ news.easynet.ch ...[color=blue]
            > "Garp" <garp7@no7.blue yonder.co.uk> schrieb im Newsbeitrag
            > news:TE5fc.3163 $c65.30009465@n ews-text.cableinet. net...[color=green]
            > >
            > >
            > > It's fine, your errors are really warnings as a result of the first run[/color][/color]
            of[color=blue][color=green]
            > > the script not having anything in the $_POST variable to use as value=
            > > attributes; presumably you've put them there because you want to repost[/color]
            > the[color=green]
            > > same data if there's an error.
            > >
            > > You could code round it, but it's easier to just put
            > > error_reporting (E_ERROR);
            > > at the top once you're satisfied that it works to your satisfaction. Or,
            > > like me, even change the default in php.ini so that E_ERROR is usual and[/color]
            > put[color=green]
            > > error_reporting (E_ALL); at the top of scripts that you're debugging.[/color]
            >
            > Killing notices IMO is not debugging, but rather bugging! You can disable
            > the notice reporting _after_ debugging on going online, to prevent notices
            > from being displayed to the public, but they are essential for debugging.
            >
            > For a quick solution, just fill the variables before you display the form:
            >
            > if(isset($_POST['sender_name'])) $sender_name=$_ POST['sender_name'];
            > else $sender_name="" ;
            >
            > ... and so on. After that you just use $sender_name. Also note the[/color]
            'quotes'[color=blue]
            > inside the ['brackets'].
            >
            > A better solution would be to display the form at the end of the code[/color]
            flow.[color=blue]
            > So you can handle all your variable checking, then display a thank you
            > message if all is ok or display the form again with the messages and the
            > entries if it has to be resubmitted.
            >
            > HTH
            > Markus
            >
            >[/color]

            Makes sense. As I said, I'm new to this. The form does what it has to, so
            turning off debugging worked fine.

            But I also see how filling the variables would work. Thanks for the tip. I
            am sure I will use it in the future. For now this school assignment has
            taken enough of my time.

            Thanks to everyone for the help.


            Comment

            Working...