I want to move a value from page stepone php to page steptwo php the value is generated automatically by js on stepone php, and then I want to use the same value ( id for the submission ) on steptwo php any ideas ?
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<form action="action_pageone.php" method="POST">
<label for="FullName">Full Name</label><br>
<input type="text" id="FullName" name="FullName"><br>
<!-- this input -->
<input type="hidden" name="ID" id="ID" value="" maxlength="16" size="16">
<!-- this input -->
<input type="submit" value="Submit">
</form>
<script>
function randomNumber(len) {
var randomNumber;
var n = '';
for (var count = 0; count < len; count++) {
randomNumber = Math.floor(Math.random() * 10);
n += randomNumber.toString();
}
return n;
}
window.onload = function() {
document.getElementById("ID").value = randomNumber(9);
};
</script>
</body>
</html>
and the action_pageone here it is so i need to copy this ID to the other page mentioned ( steptwo) the exact ID
<?php
$ID = $_POST['ID'];
$FullName = $_POST['FullName'];
// Database Connection
$servername = "localhost";
$username = "";
$password = "";
$db = "";
$conn = new mysqli('localhost', 'username', 'password', 'db') or die($conn->connect_error);
$conn->set_charset("utf8");
if ($conn->connect_error){
die("Connection failed: ". $conn->connect_error);
}
$sql = "insert into Registration(ID,FullName) values('$ID','$FullName')";
if ($conn->query($sql) === TRUE) {
header('location: steptwo.php');
} else {
echo " Registration not Success ";
}
$conn->close();
?>
any suggestions guys ?
for me it doesnt matter if its js or php , i need it to work :(