I have a small form at the top of each page that, after validation, is meant to redirect to a search page based on the input result. However, I find that it doesn't work on my local setup, yet works fine on the remote setup.
On my localhost, I get the error:
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\rw-pw\includes\wrapper.php:13) in C:\xampp\htdocs\rw-pw\includes\wrapper.php on line 75
...which does not occur on the remote server.
<div style="float:right;margin-right:5px;margin-top:5px;clear:right">
<FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD="post" ENCTYPE="multipart/form-data" NAME="mlsSearch" TITLE="mlsSearch">
<input name="mlsnum" type="hidden" value="<?php echo trim($_POST['mlsnum']); ?>" />
<input name="PropertyType" type="hidden" value="<?php echo $PropertyType; ?>" />
<INPUT NAME="mlsnum" TYPE="text" VALUE="" SIZE="10" MAXLENGTH="6" onfocus="style.borderColor='#000000';" onblur="style.borderColor='#cccccc';" /><input type="submit" name="mlssubmit" value="Find MLS#" /></form>
</div>
<?php
if ($_POST['mlssubmit']) {
$mlsnum = trim($_POST['mlsnum']);
if (!Validate::isNotEmpty($mlsnum)) {
$errmsg = "<span style=\"font-size:12px;font-weight:bold;color:red;\">Please enter an MLS number.</span>";
}
elseif(Validate::isInteger($mlsnum)) { //if data entered is all integers, do this
$validlength = 6;
if (strlen($mlsnum) != $validlength) {
$errmsg = "<span style=\"font-size:12px;font-weight:bold;color:red;\">A valid MLS number is 6 digits.</span>";
}
} elseif(!Validate::isInteger($mlsnum)) {
$errmsg = "<span style=\"font-size:12px;font-weight:bold;color:red;\">A valid MLS number is 6 digits, only numbers.</span>";
}
if ($errmsg) {
echo "<div style=\"float:right;padding-top:-10px;clear:right;\">".$errmsg."</div>";
} else {
$mlsnum = trim($_POST['mlsnum']);
header("Location: http://".$_SERVER['HTTP_HOST']."/listingsDetail.php?mlsnum=".$mlsnum."");
}
}
?>
</div>
A bit more info: dev box is Windows latest XAMPP install (Apache 2.2.3, MySQL 5.0.24a, PHP 5.1.6) and remote/production box is php 4.4.4, Apache/1.3.37 (Unix), mysql 5.0.19. I'm not using any of the 'extras' special to php5 and apache2.2. Let it be known I'm about ready to toss out this new PC laptop and get a Mac; it's been driving me nuts to develop from Windows to Unix as I usualy develop on a Unix or Unix-based platform.
Having said that, I checked to ensure there are no spaces before and after the opening/closing PHP tags. I read somewhere that you should have no code following the header function; is there then another way I need to accomplish this?
Thanks,
Eve