PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
GUYS I NEED HELP. I use echo to print my form. there is a submit button on the first set of forms. i tried posting it and it works. then i need to have another submit button and used echo again to display that. but there is an error saying: unidentified index delete. I've been trying to fix my code but I can't seem to find what's wrong. HELP GUYS here is the code.
echo "
<h1>Delete Accounts</h1>
<form action = 'delete.php' = method= 'post'>
Enter Username:<input type = 'text' name = 'lookup'>
<input type = 'submit' name = 'submit' value='Search'>";
if(isset($_POST['submit']))
{
$x = mysql_query("SELECT * FROM tblaccounts WHERE username = '$_POST[lookup]'");
$row = mysql_fetch_array($x);
if($row)
{
$user = $row['username'];
$eadd = $row['email'];
$fname = $row['firstname'];
$nname = $row['nickname'];
$lname = $row['lastname'];
echo"
<table border = 0>
<tr><td>Username : </td><td>$user<td></tr>
<tr><td>Password : </td><td>*****<td></tr>
<tr><td>Email-Address : </td><td>$eadd<td></tr>
<tr><td>First Name : </td><td>$fname<td></tr>
<tr><td>Nickname : </td><td>$nname<td></tr>
<tr><td>Last Name : </td><td>$lname<td></tr>
</table>";
echo "<input type = 'submit' name = 'delete' value = 'Delete'></td></tr><br><br>";
if($_POST['delete'])
{
echo "Are you sure you want to delete $user's details?
<tr><td><input type = 'submit' name = 'yes' value = 'SUBMIT'><input type = 'submit' name = 'no' value = 'No'><br><br></td></tr>
</form>";
if($_POST['yes'])
{
mysql_query("DELETE FROM tblaccounts Where username = '$_POST[lookup]'");
}
}
}
Last edited by Benjamin on Thu Nov 17, 2011 7:46 am, edited 1 time in total.
Reason:Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.