After my users submit some basic info in a form, how do I get the newly created userID to be echoed back to a hidden field on the header (redirect) page?
The first form contains basis Name, Phone, Email inputs. When user submits form (to database), the AI 'userID' column generates their unique 'userID'.
I need that unique ID to echo back to a hidden field on the header (redirect) page where the user will then upload their profile photo.
New User Form:
<h1>New User Form</h1>
<form action="newUser_formHandler.php" method="POST" >
<input name="userName" placeholder="Enter Name"><br><br>
<input name="userPhone" placeholder="Enter Phone"><br><br>
<input name="userEmail" placeholder="Enter Email"><br><br>
<input type="submit" name="submit" value="Submit">
</form>
New User Form Handler:
<?php include './secure/dbKey.php';?>
<?php
if(isset($_POST['submit'])){
$userName = $_POST['userName'] ;
$userPhone = $_POST['userPhone'] ;
$userEmail = $_POST['userEmail'] ;
$newUser = "insert into Users (userName, userPhone, userEmail)
values('$userName', '$userPhone', '$userEmail')";
$run = mysqli_query($conn,$newUser) or die(mysqli_error()) ;
//Page Re-direct after form submission
header('location: /profilePhoto_UploadPage.php');
}
?>
Profile Photo Upload Page:
<?php include './secure/dbKey.php';?>
<html>
<head>
<title>Profile Photo Upload Page</title>
</head>
<body>
<h1>Congratulations!</h1>
<h2>Your profile was succesfully created!</h2>
<a>Please upload a photo to complete your profile:</a><br><br>
<form action="photoUpload_Handler.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="userID" id="userID" value="<?php echo $userID; ?>">
<input type="file" name="fileToUpload" id="fileToUpload"><br><br>
<input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>