Forum Moderators: coopster

Message Too Old, No Replies

php fields required help

need help adding required fields

         

bgoldenrulz

2:19 am on Jun 14, 2008 (gmt 0)

10+ Year Member


Im new to php and dont really understand it yet but I need help adding a code to require feilds in a php form on my site. I need all the feilds required.

The file content....
__________________________________________________________________
<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";

if (file_exists(INFUSIONS."button_panel/locale/".$settings['locale'].".php")) {
include INFUSIONS."button_panel/locale/".$settings['locale'].".php";
} else {
include INFUSIONS."button_panel/locale/English.php";
}

switch ($axn) {
default:
$result = dbquery("SELECT * FROM ".$db_prefix."buttons");
$rows = dbrows($result);
if ($rows>0) {
echo "
<table width='100%' cellpadding='3' cellspacing='1' border='0' align='center' style='margin-top:1em;margin-bottom:1em;'>
<tr>

</tr>";
while ($data = dbarray($result)) {
echo "
<tr>

</tr>";
}
echo "
<tr>
<td align='center' class='tbl2' colspan='8'><p>Affiliate account successfully created.</p></td>
</tr>
</table>
";
} else {
echo "<div style='text-align:center'><p style='margin-top:2em'><span style='color:#cc0000; weight:bold;font-size:1.5em;'>".$locale['BLAN_102']."</span></p>
<p style='margin-bottom:2em'><a href='".FUSION_SELF."?axn=add'>".$locale['BLAN_103']."</a></p></div>";
}
break;
case 'add':
if (isset($_POST['add_button'])) {
dbquery("INSERT INTO ".$db_prefix."buttons VALUES('', '".$_POST['butname']."', '".$_POST['butpic']."', '".$_POST['butlink']."', '0', '".$_POST['butuser']."', '".$_POST['butpass']."')");
redirect (FUSION_SELF, "script");
} else {
echo "
<form action='".FUSION_SELF."?axn=add' method='post' style='margin:2em;'>
<table width='60%' cellpadding='3' cellspacing='1' border='0' align='center'>
<tr height='40'>
<td align='center' class='tbl2' colspan='2'><span style='font-weight:bold;font-size:1.5em;'>".$locale['BLAN_121']."</span></td>
</tr>
<tr>
<td class='tbl1' align='right' width='35%' style='font-weight:bold;'>".$locale['BLAN_105']."</td>
<td class='tbl1' align='left' width='65%'><input type='text' name='butname' size='40' class='textbox'></td>
</tr>
<tr>
<td class='tbl1' align='right' style='font-weight:bold;'>".$locale['BLAN_106']."</td>

<td class='tbl1' align='left'><input type='text' name='butpic' size='40' class='textbox'></td>
</tr>
<tr>
<td class='tbl1' align='right' style='font-weight:bold;'>".$locale['BLAN_107']."</td>
<td class='tbl1' align='left'><input type='text' name='butlink' size='40' class='textbox'></td>
</tr>
<tr>
<td class='tbl1' align='right' style='font-weight:bold;'>".$locale['BLAN_108']."</td>
<td class='tbl1' align='left'><input type='text' name='butuser' size='40' class='textbox'></td>
</tr>
<tr>
<td class='tbl1' align='right' style='font-weight:bold;'>".$locale['BLAN_109']."</td>
<td class='tbl1' align='left'><input type='text' name='butpass' size='40' class='textbox'></td>
</tr>
<tr height='40'>
<td align='center' class='tbl1' colspan='2'><input type='submit' name='add_button' value='".$locale['BLAN_122']."' class='button'></td>
</tr>
</table>
</form>";
}
break;
case 'edit':
if (isset($_POST['edit_button'])) {
dbquery("UPDATE ".$db_prefix."buttons SET button_name='".$_POST['butname']."', button_pic='".$_POST['butpic']."', button_link='".$_POST['butlink']."', button_user='".$_POST['butuser']."', button_pass='".$_POST['butpass']."' WHERE button_id='".$_POST['but_id']."'");
redirect (FUSION_SELF, "script");
} else {
$result = dbquery("SELECT * FROM ".$db_prefix."buttons WHERE button_id=".$but_id."");
$data = dbarray($result);
echo "<form action='".FUSION_SELF."?axn=edit' method='post' style='margin:2em;'>
<p>
<table width='60%' cellpadding='3' cellspacing='1' border='0' align='center'>
<tr height='40'>
<td align='center' class='tbl2' colspan='2'><span style='font-weight:bold;font-size:1.5em;'>".$locale['BLAN_119']."</span></td>
</tr>
<tr>
<td class='tbl1' align='right' width='35%' style='font-weight:bold;'>".$locale['BLAN_105']."</td>
<td class='tbl1' align='left' width='65%'><input type='text' name='butname' size='40' class='textbox' value='".$data['button_name']."'></td>
</tr>

<tr>
<td class='tbl1' align='right' style='font-weight:bold;'>".$locale['BLAN_106']."</td>
<td class='tbl1' align='left'><input type='text' name='butpic' size='40' class='textbox' value='".$data['button_pic']."'></td>
</tr>
<tr>
<td class='tbl1' align='right' style='font-weight:bold;'>".$locale['BLAN_107']."</td>
<td class='tbl1' align='left'><input type='text' name='butlink' size='40' class='textbox' value='".$data['button_link']."'></td>
</tr>
<tr>
<td class='tbl1' align='right' style='font-weight:bold;'>".$locale['BLAN_108']."</td>
<td class='tbl1' align='left'><input type='text' name='butuser' size='40' class='textbox' value='".$data['button_user']."'></td>
</tr>
<tr>
<td class='tbl1' align='right' style='font-weight:bold;'>".$locale['BLAN_109']."</td>
<td class='tbl1' align='left'><input type='text' name='butpass' size='40' class='textbox' value='".$data['button_pass']."'></td>
</tr>
<tr height='40'>
<td align='center' class='tbl1' colspan='2'><input type='hidden' name='but_id' value='$but_id'><input type='submit' name='edit_button' value='".$locale['BLAN_114']."' class='button'></td>
</tr>

</table>
</p>
</form>
";
}
break;
case 'del':
if (isset($_POST['del_button'])) {
dbquery("DELETE FROM ".$db_prefix."buttons WHERE button_id=".$_POST['but_id']."");
redirect (FUSION_SELF, "script");
} else {
$result = dbquery("SELECT * FROM ".$db_prefix."buttons WHERE button_id=".$but_id."");
$data = dbarray($result);
echo "<form action='".FUSION_SELF."?axn=del' method='post' style='margin:2em;'>
<table width='50%' cellpadding='3' cellspacing='1' border='0' align='center'>
<tr height='40'>
<td align='center' class='tbl2'><span style='font-weight:bold;font-size:1.5em;'>".$locale['BLAN_120']."</span></td>
</tr>
<tr>
<td class='tbl1' align='center' width='35%'><p style='padding:2em;'>".$locale['BLAN_118']."<span style='font-weight:bold;'>".$data['button_name']."</span>?</td>
</tr>
<tr>
<td align='center' class='tbl1'><input type='hidden' name='but_id' value='$but_id'><input type='submit' name='del_button' value='".$locale['BLAN_116']."' class='button'>
<input type='button' onclick=\"history.go(-1);\" value='".$locale['BLAN_117']."' class='button'></td>
</tr>

</table>
</form>";
}
break;
}
require_once BASEDIR."footer.php";
closetable();

?>
_____________________________________________________________________

trigoon

1:23 pm on Jun 14, 2008 (gmt 0)

10+ Year Member



What script is that? Most scripts give you the option to make fields required. The best option is to go with javascript and php. If javascript isn't something you want PHP is also sufficient. But for what you want we need more than just that. All fields need to be checked against to make sure they aren't left blank.

bgoldenrulz

6:39 pm on Jun 14, 2008 (gmt 0)

10+ Year Member



its a php form for affiliates to sign up. the script orginally only allowed admins to add accounts but i turned it to a page where affiliates can register. But the form submits even if none of the feilds are filled in. trust me i tested it. im not really sure what else you mean.