Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP 'Checkbox' Alternative when updating
    primarykey
    data
    text
    <p>I have a small problem with my PHP Code and as always, any help is hugely appreciated.</p> <p>The code was originally designed by another person and I seem to have come across a problem that I can't fix.</p> <p>The structure of the page is as follows:</p> <ol> <li>A while loop to output the data, each of course, has a unique id.</li> <li>A checkbox that must be ticked before pressing the 'update' button (several update buttons present pending on how many rows are returned.</li> </ol> <p>This is what i'm confused on, he has designed it to they must tick the 'checkbox' before pressing update, otherwise, the script doesn't know which 'id' to update. Why is it like this?!</p> <pre><code>&lt;?php if($_POST['accept']){ if(!$_POST['check']){ echo "&lt;div class='error_input'&gt;Error! please tick box to confirm &lt;/div&gt;"; }else{ $form_id=$_POST['fid']; $customer=$_POST['customer']; mysql_query("UPDATE job SET customer='$customer'WHERE f_id=$form_id "); echo "&lt;div class='form_ok'&gt;Job has been updated.&lt;/div&gt;"; } ?&gt; </code></pre> <p>If I just comment out the check box, and the user clicks the 'accept' button, it doesn't work, so clearly the 'checkbox' is pointing to the unique ID of the row, but I can't see it?</p> <pre><code>&lt;input type="checkbox" name="check" value="1" required/&gt; &lt;input type="submit" name="accept" value="Accept Job"&gt; </code></pre> <p>My issue is, I want to be able to remove this annoying checkbox, and once the user has pressed 'accept' add the unique ID into a session, which I know can be done by:</p> <pre><code>$_SESSION['user_id'] = $user_id; </code></pre> <p>As they then get redirected to a pop-up box to which I need this unique ID to pull further data from the database.</p> <p>I've had a go at implemented this:</p> <pre><code>&lt;input type="submit" name="accept" value="&lt;?php echo"$user_id"; ?&gt;" class="sbutton"&gt; </code></pre> <p>which works in a nutshell, how ever, it's not user friendly and I can't access the user_id, when I use the <code>$_POST</code> feature, it saves the 'name' field.</p> <p>I know this is long winded, I hope i've given you enough information, many thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload