Ok, I have a very strange issue.. My site has some error detection stuff for when dealing with forms.
Basically, I've got input boxes and drop downs.. If you don't make choices and click submit, it takes you to the anchor "errordetect", so where the php outputs "you need to select a quantity" or "you need to select a size"...
The problem originally came about because I noticed internet explorer ignores anchors 50% of the time, so if there was a problem it would just sit at the top of the page and it would not look like there was an error... So I decided to start the page with
if (error == 1) {
echo "there was an error";
}
... Ok, but here's the weird thing:
my actual code for the error goes like this:
if ( ($header=="submit") )
{
if ($myerr == 1)
{
echo "<h4>There was an error, please make sure all fields are
completed.</h4>";
}
else
{
echo "<h4>Processing Your Order...</h4>";
}
}
... bla bla..
errcheck ($theitem,$account,$thelocation);
function errcheck ($iteminfo,$account,$thelocation)
{
$error = 0;
if (isset($_POST['submit']))
{
if (empty($_POST['thequantity'])) {
$error = 1;
if (!empty($errstr)) {
$errstr = "*** Please select the quantity you wish to purchase! ***";
}
}
if ($error==0) {
fp_lib_refresh (1,"https://www.paypal.com/cart/add=1&quantity=$thequantity&business=$account")
else
{
$this_url_location=$_SERVER['REQUEST_URI'];
echo "<p class='error'><span class='error2'>Your purchase could not be completed for the following reason(s):</span></p><p class='error'>$errstr</p><a name='errordetect' id='errordetect'></a>";
echo "<script type='text/javascript'>location.href = '".$this_url_location."&myerr=1#errordetect';</script>";
}
}
}
So what ends up happening is, if I remove the &myerr=1 from the javascript line: location.href = '".$this_url_location."&myerr=1#errordetect'
then my P class='error' text appears and says why the error occured... But then at the top of the screen I don't get a "there was an error" message.
If I keep the myerr=1 then for some strange reason I cannot figure out, the $_POST['thequantity'] seem to not be empty or something because no error text shows up on clicking submit.. I only get the "there was an error" message at the top!
Can anyone tell me why this is happening?
-patrick