Re: Notice: Undefined index: op

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you everyone for your help. None of the solutions helped though. It is a long story, I have to use the undefined 'op' in a few places and all f the solution end up causing other error. But I appreciate the help and I understand when the problem is alot clearer.. I just turned off the error reporting like everyone suggested. Maybe when I learn a bit more I can go back and fix it. My application runs fine, I just like everything to be 'perfect'.
jzf




Martin Norland wrote:

J. Connolly wrote:

I get the error message:

*Notice*: Undefined index: op

When trying to set up a form. I have looked everywhere for the solution. I don't understnadn how to define that index. The come it comes from is:

if ($_POST['op'] != 'ds') {
$display_block = "
<form action=\"$_SERVER[PHP_SELF]\" method=\"POST\">
Your E-mail Address:
<input type=text name=\"email\" size=40 maxlength=150/>
<input type=radio name=\"action\" value=\"sub\" checked/>subscribe<br/>
<input type=radio name=\"action\" value=\unsub\" />unsubscribe
<input type=\"hidden\" name=\"op\" value=\"ds\"/>
<input type=submit name=\"submit\" value=\"Submit Form\"/>
</form>";
}


I am trying to create a form which allows my users to join a mailing list. I conceptually understand what the problem is but cannot find out how to solve the problem. I cannot find out how to define 'op'. Please do not tell me to lower my error reporting levels. I would rather fix the problems. Thank you,
Joseph

$_POST is likely empty, because the user requesting the page has likely not submitted the form (yet). What you probably want (since you aren't going to lower the error reporting levels) is:


if ( isset($_POST['op']) && $_POST['op'] == 'ds' ) {
    // do your operation here
} else {
    // print your form/etc. here
}

You may want to use a different quoting style - I can't recall the name, but it's taken from perl

echo <<<EOF
<form action="$_SERVER[PHP_SELF]" method="POST">
...
the rest of your stuff, then on its own line right at the beginning of the line (no tabs/etc. :( )
...
EOF;


it basically echo's until it sees that delimiter, that could be EOD or STOP or whatever (well, there might be reserved words issues - I could more easily check if I could remember the name of the quoting style...)

Cheers

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux