checkbox check problem

love

Verified User
Joined
Jun 30, 2006
Messages
8
hello i got a delete form and the action file , i dont know how to make a function that checks if a checkbox is empty

delcustomer.php :
PHP:
<?php
session_start();
include "level4_check.php";

if ($order == "") {$order = "userid";}

$result = mysql_query("Select * from login_users ORDER BY '$order'",$con);
$num = mysql_num_rows($result);

$userid = mysql_real_escape_string($userid); 
$query = "SELECT COUNT(*) AS `Rows`, `userid` FROM `login_users` GROUP BY `userid` ORDER BY `userid`";
$res = mysql_query($query); 

if (mysql_num_rows($res) > 0) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<link rel="stylesheet" href="style.css" type="text/css" media="screen"/>
</head>
<body bgproperties="fixed" background="images/bg.gif" class="text">
>> delete customer
<br /><br /><br />
<form name="form1" method="post" action="delprocess.php">
<table border="1" bordercolor="#DEDCDC" align="center" dir="ltr" class="text2">
<tr>
      <td class="texttable">  delete  </td>
      <td class="texttable">  name  </td>
      <td class="texttable">  checkbox  </td>
    </tr> 
      <?php if ($row['userid'] <> "185") {  ?>
      </td>
    <?php while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$n++;
?>
    <tr>
      <td class="texttable2"><input type="Submit" name="Submit" value="" class="submit"></td>
      <input name="total" type="hidden" id="total" value="<?php echo $n ?>"></td>
      <td class="texttable2"><?php echo $row['user_name']; ?></td>
      <td class="texttable2"><input type="checkbox" checked name="d<?php echo $n; ?>" value="<?php echo $row['userid'];?>"><? } ?><? } ?></td>
    </tr>
</body>
</html>
<?
}
else 
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<link rel="stylesheet" href="style.css" type="text/css" media="screen"/>
</head>
<body bgproperties="fixed" background="images/bg.gif" class="text">
>> error
<br /><br /><br /><br />
<span class="texttable3"><center>
no exist users!
</span></center>
</body>
</html>
<?
}
?>
</table>
</form>

delprocess.php:
PHP:
<?php
session_start();
include "level4_check.php";

if ($order == "") {
$order = "userid";
}

$result = mysql_query("Select * from login_users ORDER BY '$order'",$con);
$num = mysql_num_rows($result);

while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$n++;

if ($row['userid'] <> "185") {  

echo "
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html dir='rtl'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1255'>
<link rel='stylesheet' href='style.css' type='text/css' media='screen'/>
</head>
<body bgproperties='fixed' background='images/bg.gif' class='text'>
>> delete user
<br /><br /><br /><br />
<span class='texttable3'><center>
the user <u>" . $row['user_name'] . "</u> sucessfully deleted!
</span></center>
</body>
</html>
";

}
}

if(isset($_POST['Submit']))
{
	$total = $_POST['total'];
	$td = 0;
	$i = 0;
	
	for($i = 1; $i <= $total; $i++)
	{
		if(isset($_POST["d$i"]))
		{
			mysql_query("DELETE FROM login_users WHERE userid=".$_POST["d$i"],$con);
			$td++;
			}

}
}

?>

please help me i need a function - if checkbox is empty then print error.

thx
 
Back
Top