I changed a few things on my page and now my php form isn't working. Can someone look at it and let me know where it's broken? I know I've used a lot of inline css formatting but this is a quick a dirty thing I need to put together for a project I am working on. I need you Obi Wan, you're my only hope! :)
<form action="submit.php" method="post" name="register" style="margin-right:auto; margin-left:auto;">
<div class="form-row">
<div class="col-12 col-md-9 mb-2 mb-md-0">
<input name="name" id="name" type="text" class="form-control form-control-lg" placeholder="Enter your name..." style="width:20em; margin-bottom:1em;" required>
<input name="email" id="email" type="email" class="form-control form-control-lg" placeholder="Enter your email..." style="width:20em; margin-bottom:1em;" required>
<input name="phone" id="phone" type="tel" class="form-control form-control-lg" placeholder="Enter your phone number..." style="width:20em; margin-bottom:1em;">
<input name="gsname" id="gsname" type="text" class="form-control form-control-lg" placeholder="Enter your guest or spouse's name..." style="width:20em;">
<p style=" text-align:left; font-size:26px; margin-top:1em;">Choose the date that works for you...</p>
<input type="checkbox" name="date" id="date" value="Tuesday, April 24" style="height:25px; width:25px; margin-top:.5em; float:left;" />
<p for="tuesday" style="font-size:22px; text-align:left; margin-left:2em; font-weight:bold;">Tuesday, April 24th 11 AM - 12:30 PM </p>
<br>
<input type="checkbox" name="date" id="date" value="Thursday, April 26th" style="height:25px; width:25px; margin-top:.5em; margin-bottom:.5em; float:left; " />
<p for="thursday" style="font-size:22px; text-align:left; margin-left:2em; font-weight:bold;">Thursday, April 26th 11 AM - 12:30 PM </p>
<br>
<p style=" text-align:left; font-size:26px;">Would you like our newsletter?</p>
<input type="checkbox" name="opt_in" id="opt_in" value="newsletter opt-in" style="height:25px; width:25px; margin-top:.5em; float:left; " />
<p for="tuesday" style="font-size:22px; text-align:left; margin-left:2em;">Yes, Send me your newsletter</p>
</div>
<div class="col-12 col-md-3">
<button type="submit" name="submit" class="btn btn-block btn-lg btn-primary" style="width:15em;">Register Now</button>
</div>
</div>
</form>
and my php script
<?php
if (isset($_POST['submit'])){
$name = $_POST['name']
$email = $_POST['email'];
$phone = $_POST['phone'];
$gsname = $_POST['gsname'];
$date = $_POST['date'];
$opt_in = $_POST['opt_in'];
$open = fopen("formdata.csv", "a");
fputcsv($open, array($name, $email, $phone, $gsname, $date, $opt_in));
fclose($open);
// To redirect form on a particular page
header("Location:https://www.google.com");
}
else {
header("Location:https://www.charter.com");
}
?>
Aucun commentaire:
Enregistrer un commentaire