Help me with this script please

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
alythcott
-


Joined: 16 Jul 2003
Posts: 13

PostPosted: Sat Aug 16, 2003 11:23 pm    Post subject: Help me with this script please Reply with quote

[code]
<HTML>
<?php
if ($submit=="Enter information")
{
$db = mysql_connect("localhost", "root","");
mysql_select_db("adsl",$db);
$sql = "INSERT INTO adslinfo (subname, tel, nodename, ISP, downbandwidth, upbandwidth, portnumber, VPI, VCI, VPIVCICPE, LENlogical, LENphysical, provdate) VALUES ('$subname','$tel','$nodename','$ISP','$downbandwidth','$upbandwidth','$portnumber','$VPI','$VCI','$VPIVCICPE','$LENlogical','$LENphysical','$provdate')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
}
else
{
?>
<form method="post" action="input.php">
Subname:<input type="Text" name="subname"><br>
TEL:<input type="Text" name="tel"><br>
Nodename:<input type="Text" name="nodename"><br>
ISP:<input type="Text" name="ISP"><br>
Downbandwidth:<input type="Text" name="downbandwidth"><br>
Upbandwidth:<input type="Text" name="upbandwidth"><br>
Portnumber:<input type="Text" name="portnumber"><br>
VPI:<input type="Text" name="VPI"><br>
VCI:<input type="Text" name="VCI"><br>
VPIVCICPE:<input type="Text" name="VPIVCICPE"><br>
LENlogical:<input type="Text" name="LENlogical"><br>
LENphysical:<input type="Text" name="LENphysical"><br>
Provdate:<input type="Text" name="provdate"><br>
<input type="Submit" name="submit" value="Enter information"></form>
<?
}
?>
</HTML>
[/code]

I keep getting the error below please help

Notice: Undefined variable: submit in C:\Program Files\Abyss Web Server\htdocs\input.php on line 3
Back to top View user's profile Send private message
docdunning
-


Joined: 11 Aug 2003
Posts: 14

PostPosted: Sun Aug 17, 2003 11:41 am    Post subject: Reply with quote

When this script is first executed, the variable "$submit" isnt yet defined - that only happens once you've been through once, then submitted the form.

You need to add at the top, something like

if (!isset($submit)) {
$submit = "";
}

Also - its recommended that you use the safer version for posted variables, and not rely on the automatic use of globals, so you'd refer to $_POST['submit'], and the same for all your form variables. This makes it less likely that your script can be hacked by someone entering "scriptname.php?submit=xyz", for example.
Back to top View user's profile Send private message
alythcott
-


Joined: 16 Jul 2003
Posts: 13

PostPosted: Sun Aug 17, 2003 5:16 pm    Post subject: Reply with quote

On the top where, because i did that and i got a errors
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group