0

So, I have this following snippet of code:

if (isset($_POST['type1'])) {
            mysql_query("UPDATE table SET status = 1 WHERE id = '". $_GET['repid']."'", $c2) or die(mysql_error());
        }
    if (isset($_POST['type2'])) {
            mysql_query("UPDATE table SET status = 1 WHERE id = '". $_GET['repid']."'", $c2) or die(mysql_error());
        }
    if (isset($_POST['type3'])) {
            mysql_query("UPDATE table SET status = 1 WHERE id = '". $_GET['repid']."'", $c2) or die(mysql_error());
        }
    ?>
    <br />
    <form method="get" action="">
        <input type="hidden" name="pageid" value="plyrmgmt">
        <input type="hidden" name="action" value="changeBan">
        <input type="hidden" name="uid" value="<?php echo $hr_uid; ?>">
        <input type="hidden" name="repid" value="<?php echo $rid; ?>">
        <input type="submit" name="type1" value="Type1">
    </form>
    <form method="get" action="">
        <input type="hidden" name="pageid" value="plyrmgmt">
        <input type="hidden" name="action" value="changeMute">
        <input type="hidden" name="uid" value="<?php echo $hr_uid; ?>">
        <input type="hidden" name="repid" value="<?php echo $rid; ?>">
        <input type="submit" name="type2" value="Type2">
    </form>
    <form method="get" action="">
        <input type="hidden" name="pageid" value="plyrmgmt">
        <input type="hidden" name="action" value="changeLock">
        <input type="hidden" name="uid" value="<?php echo $hr_uid; ?>">
        <input type="hidden" name="repid" value="<?php echo $rid; ?>">
        <input type="submit" name="type3" value="Type3">
    </form>

However, when I click the Submit button for Type1, Type2, or Type3, the query doesn't execute.

Can anyone help?

Thanks,
Mark

5
Contributors
11
Replies
12
Views
5 Years
Discussion Span
Last Post by fobos
2

The method of your form is wrong!

In PHP you're working with _POST & _GET and form with_GET.

Change the variable that will run smoothly!

1

First off i see that you are using double quotes on the id after $_GET. The only time you use get, is when you are passing variable through a URL, in this case you are not.

mysql_query("UPDATE table SET status = 1 WHERE id = '". $_GET['repid']."'", $c2) or die(mysql_error());

Needs to be

mysql_query("UPDATE table SET status = 1 WHERE id = '". $_POST['repid']."',$c2) or die(mysql_error());

And just like bollabr said, change your forms from method="get" to method="post" action="<?php $_SERVER['PHP_SELF'] ?>". Also, what is $c2 for because you are not referencing to a field to update?

0

the connection does not need to go into your update statement, its supposed to go before it.

0

mysql_query("UPDATE table SET status = 1 WHERE id = '". $_POST['repid']."'",$c2) or die(mysql_error());

missing the closing double quote!

<form method="post">

just change each form's method to post and update the queries like fobos wrote and that should work

You may want to add die(mysql_error($c2)); as if there is one and its not the default connection you won't know

0

Use method of "POST" type and mark the thread as solved if ur problem is solved.

0
if (isset($_POST['type1'])) {
echo $_POST['repid'];
        mysql_query("UPDATE table SET status = 1 WHERE id = '". $_POST['repid']."'", $c2) or die(mysql_error());
    }
if (isset($_POST['type2'])) {
 echo $_POST['repid'];
        mysql_query("UPDATE table SET status = 1 WHERE id = '". $_POST['repid']."'", $c2) or die(mysql_error());
    }
if (isset($_POST['type3'])) {
 echo $_POST['repid'];
        mysql_query("UPDATE table SET status = 1 WHERE id = '". $_POST['repid']."'", $c2) or die(mysql_error());
    }
?>
<br />
<form method="POST" action="">
    <input type="hidden" name="pageid" value="plyrmgmt">
    <input type="hidden" name="action" value="changeBan">
    <input type="hidden" name="uid" value="<?php echo $hr_uid; ?>">
    <input type="hidden" name="repid" value="<?php echo $rid; ?>">
    <input type="submit" name="type1" value="Type1">
</form>
<form method="POST" action="">
    <input type="hidden" name="pageid" value="plyrmgmt">
    <input type="hidden" name="action" value="changeMute">
    <input type="hidden" name="uid" value="<?php echo $hr_uid; ?>">
    <input type="hidden" name="repid" value="<?php echo $rid; ?>">
    <input type="submit" name="type2" value="Type2">
</form>
<form method="POST" action="">
    <input type="hidden" name="pageid" value="plyrmgmt">
    <input type="hidden" name="action" value="changeLock">
    <input type="hidden" name="uid" value="<?php echo $hr_uid; ?>">
    <input type="hidden" name="repid" value="<?php echo $rid; ?>">
    <input type="submit" name="type3" value="Type3">
</form>

Check this,if still it is not working let me know what you are getting when echoing $_POST['repid'].
Hope it will solve your problem.You must be consistent in using GET or POST method.Somewhere you are using GET and somewhere POST.

Edited by IIM

0

$_POST['repid'] doesn't echo anything out, sadly.

0

echo $hr_uid

<?php echo $hr_uid; ?

then the problem is here..."echo $hr_uid","echo $hr_uid;"
This doesn't contain anything then.Please check if you have set any value to it or not....

0

again, why are you using the connection in your update statement!! try changing each form input to pageid1, pageid2, pageid3 and soforth for the rest

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.