home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2736
Discussions: 188,385, Posts: 2,243,517, Members: 232,615
Old January 30th, 2003, 04:19 PM   Digg it!   #1 (permalink)
Member
 
baby asp-er's Avatar
 
Join Date: Mar 2002
Location: AB, Canada
Posts: 150
php_self

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

baby asp-er is offline   Reply With Quote
Old January 30th, 2003, 05:21 PM     #2 (permalink)
Member
 
grandma's Avatar
 
Join Date: Mar 2002
Location: Northern Michigan
Posts: 89
How about just using.

<form method="post" action="NAMEOFYOURFILE.php">

Grandma

grandma is offline   Reply With Quote
Old January 30th, 2003, 05:39 PM     #3 (permalink)
Member
 
baby asp-er's Avatar
 
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...

baby asp-er is offline   Reply With Quote
Old January 30th, 2003, 05:40 PM     #4 (permalink)
Member
 
drizzle's Avatar
 
Join Date: Oct 2001
Location: Louisiana, USA
Posts: 255
Send a message via MSN to drizzle
Give this a try...

Code:
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
drizzle is offline   Reply With Quote
Old January 30th, 2003, 05:54 PM     #5 (permalink)
Member
 
baby asp-er's Avatar
 
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...
baby asp-er is offline   Reply With Quote
Old January 30th, 2003, 06:00 PM     #6 (permalink)
Member
 
drizzle's Avatar
 
Join Date: Oct 2001
Location: Louisiana, USA
Posts: 255
Send a message via MSN to drizzle
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?
drizzle is offline   Reply With Quote
Old January 30th, 2003, 06:13 PM     #7 (permalink)
Member
 
baby asp-er's Avatar
 
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.
baby asp-er is offline   Reply With Quote
Old February 1st, 2003, 09:26 PM     #8 (permalink)
Banned
 
qball's Avatar
 
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; ?>">
qball is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2899)
CPU wont boot (7)
3-days in and no threads about Gaza (160)
I think I just killed my computer w.. (24)
hp compaq nc6000 problems (139)
Upgrading RAM (5)
Folderchat Weekday thread (442)
Antec 300 bulk purchase? (11)
Worth the upgrade?? (15)
Recent Discussions
New Build ( Finally ) (3)
CPU wont boot (7)
Problem With LightScribe DVD Dr.. (0)
GLaDOS is up. (3)
HP notebook reinstall Vista NO .. (5)
Building a gaming computer advi.. (4)
hp compaq nc6000 problems (139)
Folderchat Weekday thread (442)
Creative T-3000 Subwoofer (3)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 11:13 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28