Re: New Problem
| From: | Steen Rabol | Date: | Mon, 06 Jan 2003 14:17:13 +0000 |
| Subject: | Re: New Problem | ||
| References: | 1 | Groups: | php.install |
| Request: | Send a blank email to php-install+get-9573@lists.php.net to get a copy of this message | ||
Hi
Well...
If you look at your script, you'll see that you are trying to test on $submit, the
'problem' is that you have not defined $submit, not as a local var and not as a var from
eg a URL, in other words: You are trying to test on something that you have not yet defined - IMHO
'sloppy' code.
You can however remove the error message by using the error_reporting() or change error_reporting in
the php.ini, but the best solution is to either test if the var isset or define and assign it before
using it !
eg:
if(isset($submit) && $submit === true)
{
....
}
Best
Steen
"Eugene Wolff" <eugenew@htm.co.za> wrote:
> Hi,
>
> I have the following script. When I open it says:
>
> Notice: Undefined variable: submit in
> c:\inetpub\wwwroot\phpTest9.php on
> line 4
> Although the input boxes all show fine. Obviously it does
> not do the
> first part of the code because ($submit) is not equal to
> true.
>
> <html>
> <body>
> <?php
> if ($submit){
> //Process form
> $db = mysql_connect("eugene","root");
> mysql_select_db("mydetailsonline",$db);
> $sql="insert into employees
> (first_name,last_name,cell_phone,home_phone) values
>
> ('$first_name','$last_name','$address','$position')";
> $result=mysql_query($sql);
> echo "Thank you! information entered.\n";
> }else{
> //display form
> ?>
> <form method="post" action="<?php echo
> $_SERVER['PHP_SELF']?>">
> First name:<input type="Text" name="first_name"><br>
> Last name:<input type="Text" name="last_name"><br>
> CellPhone:<input type="Text" name="Cell_phone"><br>
> Home phone:<input type="Text" name="home_phone"><br>
> <input type="Submit" name="submit" value="Enter
> information">
> </form>
> <?php
> } //end if
> ?>
> </body>
> </html>
>
> Thanks again
>
> Eugene