I am trying to change my script to show the error message on the same page, above the form instead of on another page, that I current have coded. The thing is I do not know how to do that.
Can someone help me out by showing how to do it?
<!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>
<title>Website Installation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="installer-styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
<a href="installer.php">
Website Installation</a>
</div>
<div id="main">
<div class="pad25">
<?php
if(isset($_POST['submit'])) {
if ($_POST['nextstep']=="checkuser") { //start function for the checkuser stage
if(empty($_POST['db_name']) || empty($_POST['db_user']) || empty($_POST['db_pass']) || empty($_POST['db_host']) ) {
echo "form not fully filled, reshow first form";
}
else {
?>
<HTML>
<HEAD><title>Using PHP_SELF</title></HEAD>
<BODY>
<FORM method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
second form<br>
<input type="text" name="user3"><br>
<input type="text" name="user4"><br>
<input type="hidden" name="nextstep" value="checkanswer">
<input type="submit" name="submit" value="Submit Form"><br>
</FORM>
</BODY>
</HTML>
<?php
} //end function for the checkuser stage
?>
<?php
}
if ($_POST['nextstep']=="checkanswer") { //start function for the checkanswer stage
if(empty($_POST['user3']) || empty($_POST['user4']) ) {
echo "form not fully filled, reshow first second";
}
else {
?>
complete
<?php
} //start function for the checkuser stage
?>
<?php
}
}
else {
?>
<h1>Step 1: Database Information</h1><br />
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
<p>Enter your database connection settings. These settings will be inserted into <code>inc/config.inc.php</code> and will be used by the application.</p>
<table style="width: 100%;">
<tr>
<th class="col1">Database Name</th>
<td class="col2"><input name="db_name" type="text" size="20" /></td>
<td class="col3">The name of the database to use.</td>
</tr>
<tr>
<th class="col1">Username</th>
<td class="col2"><input name="db_user" type="text" size="20" /></td>
<td class="col3">Your MySQL username.</td>
</tr>
<tr>
<th class="col1">Password</th>
<td class="col2"><input name="db_pass" type="password" size="20" /></td>
<td class="col3">Your MySQL password.</td>
</tr>
<tr>
<th class="col1">Database Host</th>
<td class="col2"><input name="db_host" type="text" size="20" value="localhost" /></td>
<td class="col3">Most likely won't need to change this value.</td>
</tr>
</table><br />
<input type="hidden" name="nextstep" value="checkuser">
<input type="submit" name="submit" class="button" style="float:right;" value="Submit Form ›"><br>
</form>
<?php
}
?>
</div>
</div>
<br class="clr" />
</div>
<br class="clr" />
<div id="footer">
<div class="footer_inner">
© 2010 | Bucket
</div>
</div>
</body>
</html>
I currently have the else message echoing on another page.