Jump to content

Form for admin to update 2 rows at same time not working.


thighmister

Recommended Posts

The table is:

 

next      next_id        id


0              2              1

1              3              2

0              4              3

0              1              4

 

 

 

The form:

 

<?php 
include 'dbc.php';
page_protect();

if(!checkAdmin()) {
header("Location: login.php");
exit();
}

  if($_POST['doSubmit'] == 'Create') {

list($next_id) = mysql_fetch_row(mysql_query("select next_id from users where id='$id'"));	

mysql_query("update users set approved='1' where id='$id'");

mysql_query("update users set next='1' where id='$next_id'");

mysql_query("update users set next='0' where id='$id'");

list($to_email) = mysql_fetch_row(mysql_query("select user_email from users where id='$id'"));	

$ret = $_SERVER['PHP_SELF'] . '?'.$_POST['query_str'];	 
header("Location: $ret");
exit();

$message = 
"Hello \n

";

@mail($to_email, "Aaaaack", $message,
    "From: \"Lobo\" <auto-reply@$host>\r\n" .
     "X-Mailer: PHP/" . phpversion()); 


}


  ?>

 <html>
  <body>
      <table width="80%" border="0" cellpadding="5" cellspacing="2" class="myaccount">
        <tr>
          <td>i<form name="form1" method="post" action="form.php">
              
                <input name="doSubmit" type="submit" id="doSubmit" value="Create">
              </p>
            </form>
            </td>
        </tr>
      </table> 
      
     </body></html>

 

 

 

I am sorry if this is posted in the wrong place!  Here to learn.  Thank you for any clues!

Link to comment
Share on other sites

Sorry, I should have been more specific about "not working."  I want the script to change the 'next' field to 0 for the logged in user, and change the 'next' field to '1' for the next user in line, as assigned by the 'next id' column.  I also hoped it would send an email to the logged in user, but that's not as important.  When I hit the "create" button, it does not change anything.  There is no error message either.

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.