Jump to content

Forms help - Confirmation page & Sticky checkbox input


zhanos

Recommended Posts

Here is my code below. What I’m having a problem with is trouble to find how to sticky my checkbox and get to the confirmation page after clicking the submit input. I also need on the confirmation page to list what fields are not filled in.

 

<head>
	<meta http-equiv="Content-Type"content="text/html; charset=utf-8' />
	<title>Assignment 4</title>
	<style type="text/css" title="text/css" media="all">
	</style>
</head>
<div align="center">
<img src="nba2k20cover.jpg" alt="nba2k20 cover" width="616" height="353" />
<br>
<br>
<?php
include('header.php');
?>
<h4> Hosted by: Zang Thao</h4>
<h5> You are required to complete every field to your best!</h5>

<body>

<?php
$name = $_POST['name'];
$comments = $_POST['comments'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$league = $_POST['league'];
$submit = $_POST['submit'];

$monthsarray = array("Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$days = range(1,31);
$daysdefault = array ('Day');
$daysarray = array_merge($daysdefault, $days);
$years = range(2002,1910);
$yearsdefault = array ('Year');
$yearsarray = array_merge($yearsdefault, $years);


?>
<form name ="fbForm" id="fbForm" action="<?php

if(($errors = NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')) {
	echo "handle.php";
	$submit = true;
} else {
	echo "index.php";
}
?>" method="post">

	<fieldset><legend>Fill out the registration form below:</legend>
	
	<?php
	if(($_POST['name'] == NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')) {
		echo "<b>Please enter a name!</b>";
	}
	?>
	<p><label>Name: <input type="text" name="name" size="20" maxlength="40" value="<?php echo $_POST['name']; ?>" /></label></p>
	<?php
	if($_POST['email'] == NULL) {
		echo "<b>Please enter your email!</b>";
	}
	?>
	<p><label>Email Address: <input type="text" name="email" size="40" maxlength="60" value="<?php echo $_POST['email']; ?>" /></label></p>
	<?php
	if($_POST['gender'] == NULL) {
		echo "<b>Please select your gender!</b>";
	}
	?>
	<p><label for="gender">Gender:</label><input type="radio" name="gender" value="M"<?php if($_POST['gender'] == "M") { echo "checked"; } ?> /> Male<input type="radio" name="gender" value="F" /> Female</label></p>
	<?php
	if($_POST['month'] == NULL) {
		echo "<b>Please enter a birthday!</b>";
	}	
	?>
	<p><label>Birth Date: 
	<select name="month">
	<?php
	foreach ($monthsarray as $value) {
		if($_POST['month'] == $value) {
			$isselected = "selected";
		} else {
			$isselected = "";
		}
	echo "<option value='$value' $isselected>$value</option> \n";
	}
	?>
	</select>
	<select name="day">
	<?php
	foreach ($daysarray as $value) {
		if($_POST['day'] == $value) {
			$isselected = "selected";
		} else {
			$isselected = "";
		}
	echo "<option value='$value' $isselected>$value</option> \n";
	}
	?>
	</select>
	<select name="year">
	<?php
	foreach ($yearsarray as $value) {
		if($_POST['year'] == $value) {
			$isselected = "selected";
		} else {
			$isselected = "";
		}
	echo "<option value='$value' $isselected>$value</option> \n";
	}
	?>
	</select></label></p>
	<?php
	if($_POST['league'] == NULL) {
		echo "<b>Please select a league!</b>";
	}
	?>
	<p><label for="league">Choose your league:</label><input type="checkbox" name="league" value="A"<?php if($_POST['opt'] == "A") { echo "checked"; } ?> /> A
	<input type="checkbox" name="league" value="B" <?php if($_POST['opt'] == "B") { echo "checked"; } ?>/> B
	<input type="checkbox" name="league" value="C" <?php if($_POST['opt'] == "C") { echo "checked"; } ?>/> C
	<input type="checkbox" name="league" value="D" <?php if($_POST['opt'] == "D") { echo "checked"; } ?>/> D</p>
	<?php
	if($_POST['comments'] == NULL) {
		echo "<b>Write down your questions/concerns if you don't have any write N/A!</b>";
	}
	?>
	<p><label>Questions/Concerns: <textarea name="comments" rows="3" cols="40"><?php echo $_POST['comments']; ?></textarea></label></p>
	
	</fieldset>
	<?php
	if ($submit) {
		echo"<script>document.getElementById('fbForm').submit();</script> ";
	} ?>
	<p align="center"><input type="submit" name="submit" value="REGISTER!" /></p>

</form>
<?php
include('footer.php');
?>


</body>
</html>

 

Link to comment
Share on other sites

Before we get to that, would you mind running your HTML through the official W3 validator? Open the page in your browser, View Source, then copy and paste it all into the "Validate by Direct Input" section. If you see any error messages, fix what they talk about. Then come on back here and post what your revised code is.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.