Jump to content

PHP MySQL Update


doomdude

Recommended Posts

Hi Guys,

 

Would someone be able to explain to me in simple English or examples what I'm doing wrong here?

 

What I'm trying to do:

 

I've got a database that's setup working fine and displaying my data on a page I've made, I've added a button to edit account and delete accounts which are working fine, however I'm simply trying to make a submit button change a 0 to a 1 in the database for the row the button is on.

 

Code:

 

accounts.php:

 

<?php include("includes/config.php"); ?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  
   <link href="style/style.css" rel="stylesheet" type="text/css" /> 
    



</head> 

<body> 
     
    <?php include("includes/header.php"); ?> 
     


    <div id="admincontent"> 
     
    <?php include("includes/navigation.php"); ?> 
    <?php include("includes/navtwo.php"); ?> 
     
    <?     
        $result = mysql_query("SELECT * FROM $dbdata WHERE pin='0'")  
                or die(mysql_error());   
         
        echo "<table border='1' cellpadding='10'>"; 
        echo "<tr> <th>ID</th> <th>Account Name</th> <th>Name</th> <th>IP Adress</th> <th>Edit</th> <th>3 Day</th> <th>7 Day</th> <th>Delete</th></tr>"; 
        while($row = mysql_fetch_array( $result )) {                 

                echo "<tr>"; 
                echo '<td>' . $row['id'] . '</td>'; 
                echo '<td>' . $row['Account_name'] . '</td>'; 
                echo '<td>' . $row['Name'] . '</td>'; 
                echo '<td>' . $row['IP_address'] . '</td>'; 
                echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>'; 
                echo '<td><form action="includes/3day.php" method="post"><input type="hidden" name="id" value="' . $row['id'] . '" /><input type="submit"></form></td>'; 
                echo '<td></td>'; 
                echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>'; 
                echo "</tr>";  
        }  
        echo "</table>"; 
    ?> 

</div> 

     
</body>

 

3day.php:

<?php 
error_reporting(E_ALL);  
ini_set("display_errors", "on");  

include("config.php"); 
$id = mysql_real_escape_string($_POST['id']); 
  
  if (isset($_POST['submit'])) 
{  
  

$query=("UPDATE $dbdata SET pin='1' WHERE id='$id'"); 
mysql_query($query); 

  
header("Location: /admin/accounts.php"); 
} 
else 
{ 
header("Location: /admin/accounts.php"); 
} 
  
?>

 

At current when I click the submit button it does nothing. :( I'm really stuck with this guys so far I've used tutorials and snippits from around the web to get to this point.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.