Jump to content

sticky form not working


mindapolis

Recommended Posts

Hi, I'm trying to make a form sticky but when I display it on the web I get a blank page. I'm following the example given in my PHP book I'm wondering if there 's an error in the book because it has 2 opening  form tags which I didn't think was right. 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
$errors=array();
if(isset($_POST['submit'])){
	validate_input(); //checks for empty fields 
	if(count($errors) !=0){
		display_form();
	}
	else {
		display_form(); 
	}
}
function validate_input(){
	global $errors;
	if($_POST["name"]  == ""){
		$errors['name']="<font color='red'>
		please enter your name </font>";
	}
}
   function display_form(){
  	global $errors;
?>
<form action="" method="post">
Name:  <input name="name" type="text" size="10" maxlength="10" value = "<?php echo $_POST[name]; ?>"/>
    <br />  
    <?php echo $errors['name']; ?>
<br />  
    Email:  <input name="email" type="text" size="15" maxlength="30" /><br />   
<input name="submit " type="submit" value="submit " />
</form>
<?php
   }
?>
</body>
</html>

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.