2012-07-24 77 views
0

在我的源當我按下刪除按鈕,isset代碼中沒有任何excuted.can一個幫助我,PHP ISSET函數不Excuted

<body> 
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> 

<?php 

$dbc=mysqli_connect("localhost","root","","elvis_store") or die("Error Connecting to Mysql Database"); 

if(isset($_POST['submit'])){ 


echo "Hello"; 
foreach($_POST['todelete'] as $delete_id){ 

$query="DELETE FROM email_list WHERE id=$delete_id"; 
mysqli_query($dbc,$query) or die("Error Querying Database"); 

} 

echo "Customer(s) Removed"; 


} 



$query="SELECT * FROM email_list"; 
$result=mysqli_query($dbc,$query)or die("Query Syntaxt is Incorrect"); 

while($row=mysqli_fetch_array($result)){ 

echo '<input type="checkbox" value="' . $row['id'] . '" name="todelete[]" />'; 
echo $row['first_name']." ".$row['last_name']." ".$row['email']; 
echo "<br/>"; 




} 



mysqli_close($dbc); 

?> 

<input type="submit" name"submit" value="Remove"/> 
</form> 




</body> 
+1

請更新與完整的代碼和格式化後你的答案。 – y2ok 2012-07-24 08:12:27

+0

你爲什麼一定'submit'變量被髮送? – zerkms 2012-07-24 08:15:21

+0

也許你還沒有發佈'提交';變量在你的形式? – pankar 2012-07-24 08:16:02

回答

3

也許這

name"submit" 

是什麼問題?

0
所有的HTML

首先是不正確 - >名稱「提交」必須是名稱=「提交」

其次,我recomened你先檢查是否$ _POST [「提交」]設置,如果是做PHP的其他表現形式。

2

嘗試:

if(isset($_POST) && !empty($_POST)) { 


}