View previous topic :: View next topic |
Author |
Message |
alythcott -
Joined: 16 Jul 2003 Posts: 13
|
Posted: Mon Aug 18, 2003 12:32 am Post subject: How do i prevent |
|
|
Entering information twice and blank information to my database
[code]
<?php
if (!isset($submit)) {
$submit = "";
}
if ($submit)
{
$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>
<?
}
?>
<?php
[/code]
Advise please |
|
Back to top |
|
 |
kodeking -
Joined: 19 Jun 2003 Posts: 15
|
Posted: Mon Aug 18, 2003 6:35 am Post subject: This is to prevent empty fields |
|
|
See comments (lines with //)
Code: |
<?php
if (!isset($submit)) {
$submit = "";
}
//begin - do this for each field you dont want empty
if(!$field_name) {
$error = 1;
}
//end
//changed the parameters
if ($submit && !$error)
{
$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>
<?
}
?>
<?php
|
[/b]
________
Mercedes-Benz Buses Specifications
Last edited by kodeking on Thu Feb 10, 2011 11:07 pm; edited 1 time in total |
|
Back to top |
|
 |
kodeking -
Joined: 19 Jun 2003 Posts: 15
|
Posted: Mon Aug 18, 2003 6:40 am Post subject: |
|
|
for the field you want to use as the limit for double posting:
Code: |
$sql = "SELECT * FROM table_name WHERE column_name = fieldname";
$result = mysql_query($sql);
$value = mysql_num_rows($result);
if($value){
$error = 1;
} |
________
MEDICAL MARIJUANA DOCTOR
________
CENSORED |
|
Back to top |
|
 |
|
|
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
|
|