0
$jepse = $_POST['slj'];
if(isset($jepse)){
    $sql43 = "UPDATE notifications SET seen='1' WHERE touser='$myid' ";
    if(mysqli_query($con, $sql43)){
    }}  
?>
<center>
<form action="#" method="POST">
<input type="submit" name="slj" value="Seen" style="background: rgba(255,255,255, 0); ">
</form>
</center>

I have very stupid problem here... My submit button wont set ..... Don't know what is problem... I have many same things on different pages and with different names... But for this it wont work .... Anyone help?

:::::::::::::::::::UPDATE:::::::::::::::::::::::

I did it with moving update code to another file and at action set that file...

4 Answers4

0

You doesn't set any values to submit to the server.

You have to change the form like this:

<center>
<form action="" method="POST">
<input type="hidden" name="slj" value="1">
<input type="submit" value="Seen" style="background: rgba(255,255,255, 0); ">
</form>
</center>

A value in the submit button is just the text printed on the button. You have to set another hidden input value and that will be sent.
Also it could be heplful to change the action to "".

  • why does it work on other forms i will update question in 1h with other forms where it works perfect.... even if i remove isset and leave just if($button) it wont work.... – StupidProgrammer Mar 26 '16 at 09:05
  • I don't think that is the problem, i checked the code without `hidden` input and it works. – Ala Alam Falaki Mar 26 '16 at 09:10
0

A submit button alone isn't enough to post a value. You should use a form field like a hidden input to post your data. I made this stupid mistake also.

<input type="hidden" name="slj" value="some-value">
DevMan
  • 538
  • 1
  • 5
  • 25
0

your codding is expected to work as is if there are no spelling mistakes somewhere: Although the

defining a POST element before checking if it is set, the program will see it as it is not defined ref: $jepse = $_POST['slj']; but that should not be the main problem why your database is not updating since once you clicked the button it was then defined.

Also in your form <form action="#"... remove the #

i.e. if you are on the same page <form action=""...

or

i.e. be direct <form action="the-php-page.php"...

<?php

    if(isset($_POST['slj'])){


        $sql43 = "UPDATE `notifications` SET `seen`='1' WHERE `touser`='$myid' ";


        if(mysqli_query($con, $sql43)){

            echo "updated";
        }

        else
        {
            echo "Error updating record: " . mysqli_error($con);
        }

        }

?>
<span>
<form action="" method="POST">

    <input type="submit" name="slj" value="Seen" style="background: rgba(255,255,255, 0); ">

</form>
</span><br>

REGARDS

Omari Victor Omosa
  • 2,814
  • 2
  • 24
  • 46
0
    <center>
    <form method="POST">
    <input type="submit" name="slj" value="Seen" style="background: rgba(255,255,255, 0); ">
    </form>
    </center>

<?php
$jepse = $_POST['slj'];
    if(isset($jepse)){
         echo "Working fine";
        }  
    ?>

Let mw know whether this code return "Working fine" or not

Nabeel
  • 147
  • 9