Page 1 of 1

'Notice: Undefined index' after turning errors up to full

Posted: Thu Apr 24, 2003 5:22 am
by deejay
Hi

I have made a few forms that write data to mySQL, these seem to work fine by all accounts but after turning errors to full I get the error
Notice: Undefined variable: submit in "address" in line 31
line 31 is

Code: Select all

<?php
if ($submit) {

?>
i have also tried $_POST['submit'] . i also have similar forms wrapped in a function that dont give me any error, so I take it that it there another way of defining the value $submit that I need to do.

Thanks

Posted: Thu Apr 24, 2003 5:38 am
by d1223m
it just means that the variable $submit has not been initialised yet.
this probably happens on the first view of the page before you have pressed the submit button.

it is much better to use $_POST['submit'] as you should not turn on register_globals. consult the manual for reasons.

Posted: Thu Apr 24, 2003 6:29 am
by twigletmac
Instead of doing

Code: Select all

if ($submit) {
for testing for the existence of a variable you should be using isset() or empty()
and as d1223m said, use $_POST, register_globals is deprecated.

Mac

Posted: Thu Apr 24, 2003 9:03 am
by deejay
cheers :) once again.