简体   繁体   中英

PHP ISSET Function Not Excuted

In My Source When I press the Remove Button,inside isset code not excuted.can any one help me,

<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>

Maybe this

 name"submit" 

is the problem?

Try:

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


}

First of all the html is incorrect -> name"submit" have to be name="submit"

Second, I recomened you to first check if $_POST['submit'] is set and if it is do the php else show the form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM