Jump to content

Isset Pages #2


-Karl-

Recommended Posts

My delete section.

if($_GET['page']=='delete' && isset($_GET['id'])) {
    $id = (int) $_GET['id'];

    echo "<font color='#FFFFFF' size='2'>Are you sure you want to delete this record</font>";
    echo "<form method='post' action='index.php?page=delete'>";
    echo "<input type='submit' value='Yes' name='yes'>";
    echo "<input type='submit' value='No' name='no'>";
    echo "</form>";

}

if ($_GET['page']=='delete' && isset($_POST['yes'])) {

    $con = mysql_connect("localhost","***","***");

    if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("***", $con);

    $sql="DELETE FROM *** WHERE `id` = '$_GET[id]'";

    if (!mysql_query($sql,$con))
    {
        die('Error: ' . mysql_error());
    }
    echo "<font color='#FFFFFF' size='2'>1 record deleted</font>";

    mysql_close($con);
}

 

Part of the edit page

<th><font color="#FFFFFF" size="1"><b><form action="index.php?page=delete" method="post">
<input type="hidden" name="id" value="{$arr['id']}">
<input type="Submit" name="delete" value="Delete">

 

Clicking yes will display "1 record deleted", however the field remains in place. It's something to do with the POST's and GET, but I'm not sure what.

 

Any help is appreciated greatly.

 

 

Link to comment
https://forums.phpfreaks.com/topic/196374-isset-pages-2/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.