I am attempting to work with and learn PHP with forms (with formoid at the moment) and am running into an issue. I'm following the tutorials I've looked at and nothing is working (correctly). I have a simple redirect script that I am intending to use to redirect someone to a page "verified.html" if they enter the correct ID and (six digit) date and to "no.html" if they do not. However, both ways I attempt to do this are not working. When I use this method:
<?php
if (isset($_POST['submit'])){
$id = $_POST['trid'];
$date = $_POST['trdate'];
}
if ($id == '555555' && $date =='080808') {
header("Location: http://ift.tt/1C6Lx52");
exit();
} else {
header("Location: http://ift.tt/1xSxVPb");
exit();
}
?>
The page redirects to "no.html" before the form even loads. After reading through another tutorial I figured I had to include the two IF statements in the "IF (isset" statement. So if I do that and use this method:
<?php
if (isset($_POST['submit'])){
$id = $_POST['trid'];
$date = $_POST['trdate'];
if ($id == '555555' && $date =='080808') {
header("Location: http://ift.tt/1C6Lx52");
exit();
} else {
header("Location: http://ift.tt/1xSxVPb");
exit();
}
}
the form will actually load, but it will not redirect anywhere no matter what I type in and submit. I was up all last night working on this and fiddling with different solutions, everything I came up with would either lead to the form not being loaded, or it was loaded and then did not redirect on input. If anyone could point me in the correct direction that would be awesome. Here is the code for the form page if that is relevant (I include the redirect.php at the beginning because if I include it elsewhere I get an error regarding header() already being sent):
<?php
include "redirect.php";
?>
<html>
<head>
<meta charset="utf-8" />
<title>Verify</title>
<meta name="viewport" content="width=device-width, initial- scale=1.0">
</head>
<body class="blurBg-false" style="background-color:#EBEBEB">
<!-- Start Formoid form-->
<link rel="stylesheet" href="formoid_files/formoid1/formoid-solid-blue.css" type="text/css" />
<script type="text/javascript" src="formoid_files/formoid1/jquery.min.js"></script>
<form action="validate.php" class="formoid-solid-blue" style="background-color:#FFFFFF;font-size:14px;font-family:'Roboto',Arial,Helvetica,sans-serif;color:#34495E;max-width:480px;min-width:150px" method="post"><div class="title"> <h2>Patient Verification</h2></div>
<div class="element-input"><label class="title">Please enter the six digit ID below:</label><div class="item-cont"><input class="large" type="text" name="trid" id="trid" placeholder="Input Number"/><span class="icon-place"></span></div></div>
<div class="element-input"><label class="title">Please enter the six digit year MMDDYY below:</label><div class="item-cont"><input class="large" type="text" name="trdate" id="trdate" placeholder="Input Number"/><span class="icon-place"></span></div></div>
<div class="submit"><input type="submit" value="Submit"></div></form>
<p class="frmd"><a href="http://ift.tt/1C6LuWQ">form builder</a> Formoid.com 2.9</p><script type="text/javascript" src="formoid_files/formoid1/formoid-solid-blue.js"></script>
<!-- Stop Formoid form-->
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire