January 30th, 2003, 04:19 PM
|
#1 (permalink)
| | Member
Join Date: Mar 2002 Location: AB, Canada
Posts: 150
|
Hi everyone...
just learning PHP & MySQL... I've got them both working can access the database etc., however whenever I use php-self I get this error...
PHP Notice: Undefined variable: submit in c:\inetpub\wwwroot\db_input_test2b.php on line 11 PHP Notice: Undefined variable: PHP_SELF in c:\inetpub\wwwroot\db_input_test2b.php on line 37
It's stopping me from being able to input to the database... is there something I need to enable in the php.ini or maybe a problem in my code? code follows...
<html>
<body>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$sql = "INSERT INTO employees (first,last,address,position) VALUES ('$first','$last','$address','$position')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Address:<input type="Text" name="address"><br>
Position:<input type="Text" name="position"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
} // end if
?>
</body>
</html>
any help is greatly appreciated!
thanks,
Baby asp-er |
| |
January 30th, 2003, 05:21 PM
|
#2 (permalink)
| | Member
Join Date: Mar 2002 Location: Northern Michigan
Posts: 89
|
How about just using.
<form method="post" action="NAMEOFYOURFILE.php">
Grandma |
| |
January 30th, 2003, 05:39 PM
|
#3 (permalink)
| | Member
Join Date: Mar 2002 Location: AB, Canada
Posts: 150
|
that's not working either... I still get
PHP Notice: Undefined variable: submit in c:\inetpub\wwwroot\db_input_test2.php on line 9 PHP Notice: Undefined variable: PHP_SELF in c:\inetpub\wwwroot\db_input_test2.php on line 25
even though I removed php_self from the script completely...
but thanks... |
| |
January 30th, 2003, 05:40 PM
|
#4 (permalink)
| | Member
Join Date: Oct 2001 Location: Louisiana, USA
Posts: 255
|
Give this a try... Code: <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> |
| |
January 30th, 2003, 05:54 PM
|
#5 (permalink)
| | Member
Join Date: Mar 2002 Location: AB, Canada
Posts: 150
|
I get the same error with that as well...
I'm using php4.2 , IIS 5.0 and MySQL (not sure what version)... if that helps anyone...
also I believe I have it set up for cgi method rather than sapi?
thanks again... |
| |
January 30th, 2003, 06:00 PM
|
#6 (permalink)
| | Member
Join Date: Oct 2001 Location: Louisiana, USA
Posts: 255
|
Is this line formatted properly? Code: echo "Thank you! Information entered.\n"; shouldn't it be... Code: echo ("Thank you! Information entered.\n"); You might have it right, I'm just not used to seeing it used that way. If you pasted all the code, that's line 11 right there.
Once I get home I'll be of much more help, but check over your code and make sure all its syntax is correct. Also, do you know if your register_globals are on or off? |
| |
January 30th, 2003, 06:13 PM
|
#7 (permalink)
| | Member
Join Date: Mar 2002 Location: AB, Canada
Posts: 150
|
my register globals are on...
I will check my code again...Thanks
is it possible I need to add some functions? or are these basic functions that are installed by default? if so, where can I find some?
I think I'm slowly getting it... seems I need to assign some variables...
Last edited by baby asp-er : January 30th, 2003 at 07:11 PM.
|
| |
February 1st, 2003, 09:26 PM
|
#8 (permalink)
| | Banned
Join Date: Oct 2001
Posts: 447
|
your syntax is a little off??? this should help: Code: <form method=post action="<?=$PHP_SELF?>">.
OR
<form method=post action="<?php echo $PHP_SELF; ?>"> |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |