I'm trying to delete a certain selected value from my MYSQL database in php..
[delete.php]
<form name="delete" method="POST" action="d3l3t3d.php">
<select name="eBox" id="nname" style="width: 290px; height:40px;">
<?php
mysql_connect("a","b","") or die("Wrong username or password");
mysql_select_db("TABLE") or die( "Unable to select database");
$query = "Select * From list";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
$name = $row['name'];
echo "<option>" . $name . "</option>";
}
echo "</select><br/><br/>"
?>
[d3l3t3d.php]
<?php
$namez = $_POST['nname'];
$name = mysql_real_escape_string($namez);
mysql_connect("a","b",
"") or die("Wrong username or password");
mysql_select_db("TABLE") or die( "Unable to select database");
mysql_query("DELETE FROM list WHERE name='$name'");
?>
I get the following ERROR:
Notice: Undefined index: nname in C:\\xampp\\htdocs\\folder\\d3l3t3d.php on line 2
$namez = $_POST['nname'];
should be $namez = $_POST['ebox'];
You select elements via their name, not id.
$namez = $_POST['nname'];
should be $namez = $_POST['eBox'];
The error: Undefined index: nname in C:\\xampp\\htdocs\\folder\\d3l3t3d.php on line 2
, means its searching for a element with attribute name = "nname"
, which of course, does not exist. you had name = "eBox"
.
just a small typo :)
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.