I am creating a button that will allow an admin to verify the image from users:
I don't know how to get the image ID when I click accept or reject.
Here's my code:
<?php
while($row = mysqli_fetch_array($result)) {
echo "<div class='grid-item'><img src='unimages/{$row['un_image']}'
onclick=onClick(this) style='width:98%' class='verifyimage' />
<form method='post' action='adminverify.php'>
<input class='button1' type='submit' name='accept' value='✓'>
<input class='button2' type='submit' name='reject' value='✘'>
</form>
</div>
";
}
mysqli_close($db);
?>
</div>
If the admin accepts, then the image should move from table2 to table1.
I know using INSERT INTO
and DELETE
will work, but how do I get the id for my picture.
Table 1:
Table 2:
Mmmh, you can use GET method for easier script:
while($row = mysqli_fetch_array($result)) {
echo "
<a href='?&action=accept&id={$row['un_id']}'>Accept</a>
<a href='?&action=reject&id={$row['un_id']}'>Reject</a>
";
}
And you use it like :
if(isset($_GET['action']) && isset($_GET['id'])) {
$image_id = $_GET['id']
// Then check if you must accept or reject with $_GET['action'] value
}
I'd add a hidden input that will be sent with the form:
echo "<div .....
<form....>
<input type='hidden' name='imageId' value='{$row['un_id']}'>
....
</form></div>";
You'll then have it in your receiving php script as
$image_id = $_POST['imageId'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.