i've this order.php page whereby customer enter their particulars and submit to the database. Before submitting into the db, it would do an error-check. If an error occur, it will display error message back onto order.php. Here is my code:
order.php
<?php
// Check to see if the form has been submitted (by checking the hidden form field $form_complete
if ($_REQUEST['form_complete'])
{
// Include the class
include("./CValidate.php");
// Initiate a new instance of the class
$my_form = new validator;
if ($my_form->validate_fields("txtName, txtCompany, txtAdd1, txtAdd2,txtCity,txtUrl,txtState_Province,txtPostal_Zip,txtPhone")&& $my_form->validURL("txtUrl"))
{
header("Location: payment.php");
exit;
}
print($my_form->error);
}//end of if statement
?>
<HTML>
<HEAD>
<TITLE>order</TITLE>
HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<form name="frmOrder" method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<input type="hidden" name="form_complete" value="1">[/COLOR
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<td width="1076" bgcolor="#FFFFFF"><TABLE WIDTH=999 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD bgcolor="#FFFFFF"><IMG SRC="images/order.gif" WIDTH=800 HEIGHT=41 ALT=""></TD>
</TR>
<TR>
<TD background="images/banner.gif"><table width="997" height="24" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="371"><div align="center" class="style5"></div></td>
<td width="373"><span class="style5">Home | order| FAQ | Contact</span></td>
<td width="253"> </td>
</tr>
</table></TD>
</TR>
<TR>
<TD height="454" valign="top" bgcolor="#FFFFFF">
<table width="943" height="440" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="921" height="440" valign="top">
<p>
<table width="417" border="1" align="center">
<tr>
<td>Contact name:</td>
<td><input name="txtName" type="text" id="txtName" value="<?php echo $_REQUEST['txtName']; ?>"></td>
</tr>
<tr> ........................................
with the above coding, the error message will be display above the webpage, which means above the banner since the code php code is done before the HTML tag. k the problem is i wanna display my error message after the top banner and not above the page. Get it?
<?php
// Check to see if the form has been submitted (by checking the hidden form field $form_complete
if ($_REQUEST['form_complete'])
{
// Include the class
include("./CValidate.php");
// Initiate a new instance of the class
$my_form = new validator;
if ($my_form->validate_fields("txtName, txtCompany, txtAdd1, txtAdd2,txtCity,txtUrl,txtState_Province,txtPostal_Zip,txtPhone")&& $my_form->validURL("txtUrl"))
{
header("Location: payment.php");
exit;
}
?> ---------------->>closing of php tag before closing the IF tag
So what i did is i close the PHP tag first without closing the IF statement and continue to display the error message and close the IF statement in the middle of the HTML page so that i can display my error where i prefer.
<html>........
<TD height="454" valign="top" bgcolor="#FFFFFF">
<table width="943" height="440" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="921" height="440" valign="top">
<p>
<?php
print($my_form->error);
}//end of if statement
?>
But if i were to do that, where ever i type in the address for order.php(ie:http://localhost/webpage/order.php), my web template and everything will disappear, leaving only the textbox and button. why is this so?