if statement - PHP "if" condition error -
error in if
condition. trying generate 5digit random no, , verify random no , textbox values ($_post['otp1'])
equal move thank.php
page else show popup error.
i did everything, if textbox values , $otp
value equal showing popup message.
following code
otp.php
<form action="otp.php" method="post"> <label>mobile :</label> <input type="text" name="mobile" /> <br /><br /> <label>otp :</label> <input type="text" name="otp1" /> <br /><br /> <input type="submit" name="send" value="verifiy" /> </form> <?php $otp = intval( "0" . rand(1,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) ); echo $otp; if(isset($_post['send'])) { $mobile = $_post['mobile']; $otp_no = $_post['otp1']; if($otp_no != $otp) \\ condition not work { echo "<script>alert('your otp worng'); window.location.replace(\"otp.php\");</script>"; } else { header('location: thank.php'); } } ?>
the problem otp code changed in form submit. have store otp code in hidden element , compare user's entered otp value.
<?php $otp = intval( "0" . rand(1,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) ); echo $otp; ?> <form action="test1.php" method="post"> <label>mobile :</label> <input type="text" name="mobile" /> <br /><br /> <label>otp :</label> <input type="hidden" name="otp" value="<?=$otp?>" /> <input type="text" name="otp1" /><br /><br /> <input type="submit" name="send" value="verifiy" /> </form> <?php //$otp = intval( "0" . rand(1,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) ); //echo $otp; if(isset($_post['send'])) { $mobile = $_post['mobile']; $otp_no = $_post['otp1']; $otp = $_post['otp']; if($otp_no != $otp) // condition not work { echo "<script>alert('your otp worng'); </script>"; } else { echo "success"; } } ?>
Comments
Post a Comment