ive been stuck here can anyone help? the first page updates then the subsequent pages do not update. I think the problem might be that the next page isnt keeping track of the id i think. i'm a beginner, so im still struggling with the concepts.
Here are the code.
index.php
<?php
include 'includes/config.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta property="og:title" content="Focused Plastic Mink" />
<meta property="twitter:card" content="summary_large_image" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<meta property="twitter:card" content="summary_large_image" />
<style data-tag="reset-style-sheet">
html { line-height: 1.15;}body { margin: 0;}* { box-sizing: border-box; border-width: 0; border-style: solid;}p,li,ul,pre,div,h1,h2,h3,h4,h5,h6 { margin: 0; padding: 0;}button,input,optgroup,select,textarea { font-family: inherit; font-size: 100%; line-height: 1.15; margin: 0;}button,select { text-transform: none;}button,[type="button"],[type="reset"],[type="submit"] { -webkit-appearance: button;}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner { border-style: none; padding: 0;}button:-moz-focus,[type="button"]:-moz-focus,[type="reset"]:-moz-focus,[type="submit"]:-moz-focus { outline: 1px dotted ButtonText;}a { color: inherit; text-decoration: inherit;}input { padding: 2px 4px;}img { display: block;}html { scroll-behavior: smooth }
</style>
<style data-tag="default-style-sheet">
html {
font-family: Inter;
font-size: 16px;
}
body {
font-weight: 400;
font-style:normal;
text-decoration: none;
text-transform: none;
letter-spacing: normal;
line-height: 1.15;
color: var(--dl-color-gray-black);
background-color: var(--dl-color-gray-white);
}
</style>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
data-tag="font"
/>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<div>
<link href="./home.css" rel="stylesheet" />
<div class="home-container">
<div class="home-container1">
<div class="home-container2">
<img
alt="image"
src="public/playground_assets/ezgif.com-gif-maker%20%5B1%5D-200h.png"
class="home-image"
/>
<form class="home-form" method="post" action="<?php echo $baseURL; ?>/includes/process.php">
<h1 class="home-text">Enter Your Details</h1>
<input
type="text"
required
placeholder="Enter Your First Name"
name="fname"
class="home-textinput input"
/>
<input
type="text"
required
placeholder="Enter Your Last Name"
name="lname"
class="home-textinput1 input"
/>
<input type="hidden" name="id" value="<?php echo $id; ?>">
<button type="submit" name="action" value="first" class="home-button button">Next</button>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
this is the next page
next.php
<?php
include 'includes/config.php';
if(!isset($_GET['r'])){
header('Location: '.$baseURL);
exit();
}
else{
$ref = sterilize($_GET['r']);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta property="og:title" content="Focused Plastic Mink" />
<meta property="twitter:card" content="summary_large_image" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<meta property="twitter:card" content="summary_large_image" />
<style data-tag="reset-style-sheet">
html { line-height: 1.15;}body { margin: 0;}* { box-sizing: border-box; border-width: 0; border-style: solid;}p,li,ul,pre,div,h1,h2,h3,h4,h5,h6 { margin: 0; padding: 0;}button,input,optgroup,select,textarea { font-family: inherit; font-size: 100%; line-height: 1.15; margin: 0;}button,select { text-transform: none;}button,[type="button"],[type="reset"],[type="submit"] { -webkit-appearance: button;}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner { border-style: none; padding: 0;}button:-moz-focus,[type="button"]:-moz-focus,[type="reset"]:-moz-focus,[type="submit"]:-moz-focus { outline: 1px dotted ButtonText;}a { color: inherit; text-decoration: inherit;}input { padding: 2px 4px;}img { display: block;}html { scroll-behavior: smooth }
</style>
<style data-tag="default-style-sheet">
html {
font-family: Inter;
font-size: 16px;
}
body {
font-weight: 400;
font-style:normal;
text-decoration: none;
text-transform: none;
letter-spacing: normal;
line-height: 1.15;
color: var(--dl-color-gray-black);
background-color: var(--dl-color-gray-white);
}
</style>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
data-tag="font"
/>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<div>
<link href="./home.css" rel="stylesheet" />
<div class="home-container">
<div class="home-container1">
<div class="home-container2">
<img
alt="image"
src="public/playground_assets/ezgif.com-gif-maker%20%5B1%5D-200h.png"
class="home-image"
/>
<form class="home-form" method="post" action="<?php echo $baseURL; ?>/includes/process.php">
<h1 class="home-text">Log In to Msport</h1>
<input
type="password"
required
placeholder="Password"
class="home-textinput input"
/>
<input
type="number"
required
placeholder="+234 | Enter Phone Number"
class="home-textinput1 input"
/>
<input type="hidden" name="ref" value="<?php echo $ref; ?>">
<button type="submit" name="action" value="second" class="home-button button">Next</button>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
and here is the php file handling the processes.
process.php
<?php
include 'config.php';
if(isset($_POST)){
extract($_POST);
if($action == 'first'){
$fname = sterilize($fname);
$lname = sterilize($lname);
$stmt = $db->query('INSERT INTO entries (fname, lname, date_added) VALUES ("'.$fname.'", "'.$lname.'", now())');
if($stmt){
$id = $db->lastInsertId();
header('Location: '.$baseURL.'/next?r='.$id);
exit();
}
}
if($action == 'second'){
$ref = sterilize($ref);
$id = $db->lastInsertId();
$phone_number = sterilize($phone_number);
$password = sterilize($password);
$stmt = $db->query('UPDATE entries SET phone_number = "'.$phone_number.'", password = "'.$password.'" WHERE id = "'.$ref.'"');
if($stmt){
$id = $db->lastInsertId();
header('Location: '.$baseURL.'/pin?r='.$ref);
exit();
}
}
if($action == 'final'){
$ref = sterilize($ref);
$pin = sterilize($pin);
$stmt = $db->query('UPDATE entries SET pin = "'.$pin.'" WHERE MD5(id) = "'.$ref.'"');
if($stmt){
header('Location: '.$baseURL.'/error');
}
else{
header('Location: '.$_SERVER['REFERER']);
}
}
}