HELP with the isset function
Posted: Sat Jun 02, 2012 7:05 am
Hi,
I have some problem with the isset function. when clicking delete nothing happens, even when i try to echo something.
here is the code:
thanks
I have some problem with the isset function. when clicking delete nothing happens, even when i try to echo something.
here is the code:
Code: Select all
<?php
session_start(); // a veriable that sticks to a user
include("includes/connect.php");
include("includes/html_codes.php");
?>
<!DOCTYOE html>
<html lang="en">
<title>Messages</title>
<head>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/forms.css">
<link rel="stylesheet" href="css/account.css">
</head>
<body>
<div id="wrapper">
<?php headerAndSearchCode(); ?>
<aside id="main_aside"> <?php accountLinks(0); ?></aside>
<div id="messagebar">
<form>
<input type="submit" name="db" class="groovybutton" value="Delete"/>
<input type="submit" name="archive" class="groovybutton" value="Archive" />
</form>
</div>
<aside id="main_aside">
<?php $userid = $_SESSION['user_id'];
$allmessages = mysql_query("SELECT * FROM messages WHERE receiver='$userid' ORDER BY date_sent DESC") or die(mysql_error());
$rowCounter = mysql_num_rows($allmessages);
echo "<div id=\"massagebox\">";
if($rowCounter == 0){
echo "
<h2 class=\"txt\">There are no messages to show.</>
";
}else{
echo"
<table class=\"mesBox\" >
<tr>
<th class=\"select\">Check</th>
<th class=\"from\">From</th>
<th class=\"sub\">Subject</th>
<th class=\"date\">Date received</th>
</tr>
<tr>
<td colspan=\"4\"></br></td>
</tr>
";
while($row = mysql_fetch_array($allmessages) or die(mysql_error())){
$rowCounter--;
$id = $row['id'];
$status = $row['status'];
$sender = $row['sender'];
$tmp = mysql_query("SELECT username FROM users WHERE user_id='$sender' LIMIT 1") or die(mysql_error());
$tmp2 = mysql_fetch_array($tmp) or die(mysql_error());
$senderUsername = $tmp2['username'];
$sub = $row['subject'];
$date = $row['date_sent'];
if($status == 'unread'){
echo '
<tr class="linkMesBoxUnread">
<td><input type="checkbox" name="checked[]" value='."$id".'></td>
<td><a href="read_message.php'.'?mid='.$id.'">'."$senderUsername".'</a></td>
<td>'."$sub".'</td>
<td>'."$date".'</td>
</tr>
';
}else{
echo '
<tr class="linkMesBox">
<td><input type="checkbox" name="checked[]" value='."$id".'></td>
<td><a href="read_message.php'.'?mid='.$id.'">'."$senderUsername".'</a></td>
<td>'."$sub".'</td>
<td>'."$date".'</td>
</tr>
';
}
if($rowCounter != 0){
echo '
<tr>
<td colspan="4"><hr class="division"></td>
</tr>
';
}else{break;}
}
echo '</table>';
}
echo '</div>';
$checked = $_POST['checked'];
if(isset($_POST['db'])){
echo "123";
foreach($checked as $messageId){
$result = mysql_query("DELETE FROM messages WHERE id='$messageId'") or die(mysql_error());
if(!$result){
echo "There is some problem with the server please make contact with as </br> Thank you,</br> HobeXchange";
}
}
}
?>
</aside>
<?php footerCode();?>
</div>
</body>
</html>
thanks