Require is giving me issues

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Theory?
Forum Contributor
Posts: 138
Joined: Wed Apr 11, 2007 10:43 am

Require is giving me issues

Post by Theory? »

The following is just test code. The difference of one line of code is the difference between my form displaying and nothing happening. Can you guess which one it is?

No? It's the second "require()" line. That file is there. I don't even call it yet, but it's requirement is halting my script, but no errors are being reported. It's very strange.

Code: Select all

<?php

require 'dbvars.php';
require 'includes/MySQLConnect.php';

	if (isset($_POST['submitted'])) {
		
		$errors = array();
			
			if (empty($_POST['username'])) {
				
				$errors[] = "Please enter your username.";
			
			} else {
				
				$username = $_POST['username'];
				
			} 
			
			if (empty($_POST['password'])) {
				
				$errors[] = "Please enter your password.";
				
			} else {
				
				$password = $_POST['password'];
			
			}
			
			if (empty($errors)) { //if there are no errors
			
				echo "There were no errors";
				
			} else {
				
				echo "There were errors";
				
			}
		
							
		} else {
		
		$pageTitle = "Login";
		
?>
		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title><?php echo $pageTitle; ?></title>
		</head>

		<body>
		<div id="header">
			<h1 class="large">employee-facing registry content</h1>
		</div>

		<div>
		<form action="login.php" method="POST">
		<p id="name" class="input">name: </p>
		<input type="text" name="username" />
		<br />
		<br />
		<p id="password" class"input">password: </p>
		<input type="password" name="password"  />
		<br />
		<br />
		<input type="hidden" name="submitted" value="true"  />
		<input type="submit" name="yay!" />
		</form>


		</div>

		</body>
		</html>
<?php

}

?>
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

Of course - require() halts the script if the file is missing (include() throws warning). You don't see any errors because display_errors is Off


Code: Select all

error_reporting(E_ALL);
ini_set('display_errors',1);

require 'dbvars.php';
require 'includes/MySQLConnect.php';
Post Reply