2014-02-09 99 views
0

有點卡在這裏與相同的錯誤未定義的偏移量, 每個按鈕點擊如果去兩個谷歌兩個如果的,甚至是來自「名稱」的值!= guy1它不跳過它,它做作業時,它會刪除什麼是應該,但它分配變量之前PHP錯誤與未定義的偏移量

<form action="deleteprog.php" method="post" > 
    <button type="submit" name="1000" id="1000" value="1000">DELETE</button> 
    <button type="submit" name="1001" id="1001" value="1001">DELETE2</button> 
</form> 



<?php 

mysql_connect("localhost", "root", "root") or die(mysql_error()); 
mysql_select_db("project") or die(mysql_error()); 


$guy1= 1000; 
$guy2= 1001; 
$name = htmlentities($_POST['1000']); 
echo $name; 
$name1 = htmlentities($_POST['1001']); 
echo $name1; 


if ($name == $guy1) 
{ 
    mysql_query("DELETE FROM progammers WHERE Sifra_zaposlenog= '1000'") 
    or die(mysql_error()); 
    echo "Member 1000 deleted"; 
} 
var_dump($name); 
if ($name1 == $guy2) 
{ 
    mysql_query("DELETE FROM progammers WHERE Sifra_zaposlenog= '1001'") 
    or die(mysql_error()); 
    echo "Member 1001 deleted"; 
} 
var_dump($name1); 


?> 
+1

看,閱讀你的代碼之前,應該清楚是什麼做你想問 - 但你有問題是一個無法理解的大泥球。所以請更詳細一些。 – carousel

回答

0
$name = (isset($_POST['1000'])) ? (int)$_POST['1000'] : null; 
$name1 = (isset($_POST['1001'])) ? (int)$_POST['1001'] : null; 
0

認沽檢查配備了一個錯誤:

<?php 
if(isset($_POST)){ 
mysql_connect("localhost", "root", "root") or die(mysql_error()); 
mysql_select_db("project") or die(mysql_error()); 

    if(isset($_POST)){ 
     if (isset($_POST['1000']){ 
     $name1 = $_POST['1000']; 
     $guy1= 1000; 
     if ($name2 == $guy2){ 
      mysql_query("DELETE FROM progammers WHERE Sifra_zaposlenog= '1000'") 
      or die(mysql_error()); 
      echo "Member 1000 deleted"; 
     } 
     }elseif(isset($_POST['1001'])){ 
     $name2 = $_POST['1001']; 
     $guy2= 1001; 
     if ($name2 == $guy2){ 
      mysql_query("DELETE FROM progammers WHERE Sifra_zaposlenog= '1001'") 
      or die(mysql_error()); 
      echo "Member 1001 deleted"; 
     } 
     }else{ 
      echo "Member not set"; 
     } 
    mysql_close(); 
    } 
} 
?>