I’m pretty new to HTML, and I’m working on a button that should redirect the user to a page.
This is my current code, housed in the page: details.php?id=?<php echo $student['id'] ?> this allows me to use php from a previous page to redirect the admin into individual users’ pages in the form of the link mentioned above. (basically the <php echo $student['id'] ?> changes the page based on the info in the database.)
Once in the page, I want to add a button which allows me to submit information and then redirect back into the same page/just refresh the page. This is my current code for it:
$add_point = '';
$errors = array('points' => '');
<label>Add Points: </label>
<input type="text" name="add_point" value="<?php echo $add_point ?>">
<div class="red-text"><?php echo $errors['points']?></div>
<form action="details.php" method="POST">
<input type="submit" name="add" value="Submit" class="btn brand z-depth-0">
</form>
if (isset($_POST['add'])) {
$add_point = mysqli_real_escape_string($conn, $_POST['add_point']);
$id = mysqli_real_escape_string($conn, $_GET['id']);
header('Location: details.php?id=$id');
}
instead of redirecting to the same page/refreshing, the page redirects to: details.php?id=$id, which is not what I want. How could I make it so that the submit button redirects/refreshes properly so the user can see the added points to the same user?
so to give some context to this page:
I have a section where I show the users current number of points (drawn from a database)
I then want to have an input feel where the admin can select the number of points to add, and then a submit button to add to the existing number of points into the database(basically what my code above is trying)
I then want to be able to use that button to refresh the page at the same time, so the admin can see the new number of points that the user has
Obviously the “inserting into SQL” bit hasn’t been done yet, so its a WIP.
(HTML and PHP tags also not in the code dump because this is ripped from a file. For those interested in the entire file, attachment is below. There are some stuff laying around though, been trying to solve this issue and im stumped)
Any help is appreciated, and thanks in advance!!!