Why I am not able to redirect after processing of page “PROCESS.PHP” ?
How We redirect on other page if otp is correct?
Pages : index.php
process.php
otp.php
my-form.php (after verification)
INDEX.PHP
<!DOCTYPE html>
<html>
<header>
<title>HTML Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<BODY>
<form name="encryptEmail" method="post" action="process.php" onsubmit="encrypt.disabled = true; return true;" >
<div>
<p>
<input type="text" name="name" placeholder="Your Full Name"></p>
<p><input type="text" name="email" placeholder="Your E-mail Address" >
</p>
<button class="btn" type="submit" name="encrypt">Continue</button>
</div>
</BODY>
</html>
PROCESS.PHP
<?php session_start(); $rndno=rand(100000, 999999);//OTP generate $message = urlencode("otp number.".$rndno); $to=$_POST['email']; $subject = "OTP"; $txt = "OTP: ".$rndno.""; $headers = "From: otp@postmanreply.com" ; mail($to,$subject,$txt,$headers); if(isset($_POST['encypte'])) { $_SESSION['name']=$_POST['name']; $_SESSION['email']=$_POST['email']; $_SESSION['otp']=$rndno; header( "Location: otp.php" ); } ?>
OTP.PHP
<?php
session_start();
if(isset($_POST['save']))
{
$rno=$_SESSION['otp'];
$urno=$_POST['otpvalue'];
if(!strcmp($rno,$urno))
{
$name=$_SESSION['name'];
$email=$_SESSION['email'];
echo "(header my-form.php)";
}
else{
echo "<p>Invalid OTP</p>";
}
}
//resend OTP
if(isset($_POST['resend']))
{
$message="<p class='w3-text-green'>Sucessfully send OTP to your mail.</p>";
$rno=$_SESSION['otp'];
$to=$_SESSION['email'];
$subject = "OTP";
$txt = "OTP: ".$rno."";
$headers = "From: otp@postmanreply.com" ;
mail($to,$subject,$txt,$headers);
$message="<p><b>Sucessfully resend OTP to your mail.</b></p>";
}
?><h2>ENTER OTP</h2>
<form>
<p><input type="password" placeholder="OTP" name="otpvalue"></p>
<p><button type="submit" name="submit">Submit</button> <button name="resend">Resend</button></p>
</form>
<div><?php if(isset($message)) { echo $message; } ?>