I have a slideshow where the user can click a button with an arrow on it pointing to go next and previous. When the user clicks on the arrow I want to save a page name in there, so it will redirect them to the correct page. I also want to store a number so when the user clicks previous or next, the integer will be saved in the correct table userTakingModule
, under the checkPoint
.
What is the best way to do this i.e. user a button
tag inside of a form
tag? I have pasted the two ways which I have so far tried to get to happen when the user clicks on one of the two arrows:
a.) Take the user back one page, by having the page1.html in the action
of one arrow, and page3.html in the other arrow
b.) Save on the button click, a value into the userTakingModule
table.
html attempt 1.)
<div class="arrow-container">
<form style="display: inline" action="dashboard.php" method="post">
<button value="1"><i class="fas fa-arrow-circle-left"></i></button>
</form>
<form style="display: inline" action="slide2.php" method="post">
<button value="3"><i class="fas fa-arrow-circle-right"></i></button>
</form>
</div>
html attempt 2.)
<div>
<form action ="dashboard.php" method = "POST"> <!-- However I may need this page link to change depending on whether they click forward or back -->
<label>Competition Categories</label>
<select name="checkPoint">
<option value="">Select</option>
<option value="1">Previous</option>
<option value="3">Next</option>
</select>
</fieldset>
<button name="save_check_point" type="submit" type="button">View</button>
</form>
</div>
The query I have so far is this:
<?php
// The module ID will always be 5, as they are in the Stress & Anxiety slideshow which has an ID of 5 in the table.
$idUsers = $_SESSION['id'];
$ModuleID = 5;
$checkPoint = $_POST['checkPoint'];
// Preparing and binding my SQL query which inserts a checkpoint number into the table
$stmt = $conn->prepare ("INSERT INTO `userTakingModule` (`userTakingModuleID`, `idUsers`, `ModuleID`, `checkPoint`) VALUES (NULL, ?, ?, ?)");
$stmt->bind_param("iii", $idUsers, $ModuleID, $checkPoint);
$stmt->execute();
?>
I've really been struggling on this for a while now so any help on this would be fantastic, thank you in advance.