Log in

View Full Version : Cross Browser Performance



Webiter
09-13-2011, 08:58 PM
Running 'Link A Friend' button on website at www.webitry.net and same workes as required in Firefox.
Getting a 500 server error when using Safari, Chrome and IE.:mad:
This is my introduction to cross browser issues!
What work arounds are necessary to get the thing working across all browsers? :o

JShor
09-13-2011, 10:02 PM
I don't see a "Link A Friend" button anywehre.

Webiter
09-13-2011, 11:02 PM
Josh,

Just either side of the phone number in the header of the pages.

FrickenTrevor
09-13-2011, 11:25 PM
Just as a heads up, im using Chrome and everything works, no server error.

I think its not the code, but the actual server its self (the people who host your site) since its an "error 500 server error". It is not a client-side problem/browser problem. It could actually be your web host provider.

Either check with your web host provider or if you've done any server side code, check for errors.

jscheuer1
09-14-2011, 01:08 AM
I tend to agree with Trevor. If you get a server error sometimes and not others, it means that sometimes the server is having problems, others not. The fact that it appears to be browser dependent is probably just a coincidence.

I see no error in Chrome, Opera, or IE 9. At least not when clicking the button. The popup pops up with a form in it. Or do you mean there's an error once the form is submitted? I didn't try that.

In any case again as Trevor says, if you're getting a server error, it's probably the server, not the browser.

djr33
09-14-2011, 04:07 AM
Works fine for me in Safari (and Firefox).

The only way the browser could change what the server does is to send a different request. The only thing about your code that looks a little unusual is that way you're using the HREF to trigger Javascript. Try the method below instead to see if that happens to fix it. I doubt it. Maybe those browsers are having issues with the JS in the HREF, but I've never seen that before.

<a href="#" onclick="popup();return false;">

jscheuer1
09-14-2011, 04:37 AM
Whoa! I just tried submitting the form. Internal Server Error 500 in Opera. Worked once in Firefox, then tried again several times and got Internal Server Error 500 in it as well. I think we're going to need to see the server side code.

djr33
09-14-2011, 05:34 AM
John, do you have any idea whether my theory could be correct? It's the only thing I can see, and I know that the request must be different if the server's response is different. I'd be a bit surprised though because the "javascript:" method is fairly common.

jscheuer1
09-14-2011, 07:40 AM
That's not where the error is occurring. It's when you submit the form in the popup. It's on the page - webitry.net/process_friend.php

We would need to see the raw PHP code of that page to have even a chance of discovering why this is happening.

Webiter
09-14-2011, 06:27 PM
Thanks Guys,

The process_friend.php code. Please excuse the extensive comments that I used here as I tried to understand what was going on ....


<?php
// never forget to start the session
session_start();
$_SESSION['form_data'] = $_POST;
?>


<html>
<head><title>Friend Link Processor</title></head>
<body>
<?php
//////////////VAIRABLES STORED HERE///////////////////////////////////////////////////////////////
$visitorcode=$_POST['visitorcode'];// VALIDATE CODE //
$status="is_ok";
$write="";
$m_name=$_POST['m_name']; $m_email=$_POST['m_email'];$f_name=$_POST['f_name'];$f_email=$_POST['f_email'];
///////////////////////////////////////COMMENCE FORM VALIDATION/////////////////////////////////////
/////////////////////STEP ONE VALIDATES THAT MY NAME IS ENTERED/////////////////////////////////////
if (strlen($m_name) <2 ) { $write.="Please enter your Name<BR />";$status="not_ok";}
////////////////////STEP TWO VALIDATES THAT MY CORRECT EMAIL ADDRESS IS USED////////////////////////
/////////////if (preg_match('/http:/', $notes))
if (!preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^", $m_email))
{ $write.="Your email address is not correct!<BR />"; $status="not_ok";}
/////////////////STEP THREE VALIDATES THAT FRIENDS NAME ENTERED/////////////////////////////////////
if (strlen($f_name) <2 ) { $write.="Please enter your Friend's Name<BR />"; $status="not_ok";}
//////////////////STEP FOUR VALIDATES MY FRIENDS EMAIL///////////////////////////////////////////////
if (!preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^", $f_email))
{ $write.="Your Friends email address is not correct!<BR />"; $status="not_ok";}
///////////////////STEP FIVE VALIDATES NUMBER OF EMAIL ADDRESSES USED/////////////////////////////////
if(substr_count($m_email,"@") > 1 or substr_count($f_email,"@") > 1)
{ $write.="Use only one email address please<BR />";$status="not_ok";}
if(empty($visitorcode))
{ $write.="Do not forget to fill out the <b>VALIDATE</b> code!<BR />";$status="not_ok";}
if(empty($inputfields))
{ echo "<center><font face='Verdana' color='grey'><h3>Please note the following :-</h3><font face='Verdana' size='2' color=red>$write</font><center>";}

/////////////////Captcha Validation to block Spambots//////////////////////////////////////////////////////
if (md5($visitorcode) == $_SESSION['image_random_value'])
/* echo "<h2>Code $visitorcode valid </h2>\n"; */
///////////////////////////// INSTALL MESSAGE HERE ////////////////////////////////////////////////////
{$header_message="Hi $f_name , \n\nYour friend $m_name invites you to visit Website at www.webitry.net \n\nYou can view a eCommerce Shopping Demonstration just to see how easy it is to sell online. \n\nIf you or any of your friends would like to sell online just contact the Webitry and discuss your requirement. They will be delighted to hear from you.\n\nHave a nice day!";

$body_message=$header_message."\n";
//// MAIL POSTING STARTS HERE /////////
$headers="";
//$headers="Content-Type: text/html; charset=iso-8859-1\n".$headers;
// Un comment the above line to send mail in html format
$headers4=$m_email; // Change this to change from address
$headers.="Reply-to: $headers4\n";
$headers.="From: $headers4\n";
$headers.="Errors-to: $headers4\n";
$subject="$m_name - Invitation to visit Website";
mail($f_email,$subject,$body_message,$headers);
///////////////////// END OF POSTING /////////////// & PRESENTING THANK YOU PAGE /////////////////////
echo "<center><font face='Verdana' size='3' color=green><br />Thank You, <br /><br />You sent a link for this Website to your friend $f_name. This is a great help to us. Your assistance is much appreciated.<br /><h3>The Webmaster.</h3></font></center>";
}else{
echo "<center><br /><font face='Verdana' size='2' color=blue>Your message was not sent because you entered the invalid letters - <b>$visitorcode</b><br />Please note that the letters are case sensitive. </font></center>\n";
echo '<center><br /><form action="form_friend.php"><input type="submit" value="Go Back to Form"></form></center>';
}
?>
</body>
</html>


The following is the form_friend.php code


<form method="post" action="process_friend.php">
<legend>Send Website Link to my Friend.</legend><br />
<label>My Name: </label><input type='text' id="textfield" name='m_name' value='
<?php if(isset($_SESSION['form_data']['m_name'])) { echo htmlspecialchars($_SESSION['form_data']['m_name']);}?>
' /><br />
<label>My Email: </label><input type='text' id="textfield" name='m_email' value='
<?php if(isset($_SESSION['form_data']['m_email'])) { echo htmlspecialchars($_SESSION['form_data']['m_email']);}?>
' /><br />
<label>Friend's Name: </label><input type='text' id="textfield" name='f_name' value='
<?php if(isset($_SESSION['form_data']['f_name'])) { echo htmlspecialchars($_SESSION['form_data']['f_name']);}?>
' /><br />
<label>Friend's Email: </label><input type='text' id="textfield" name='f_email' value='
<?php if(isset($_SESSION['form_data']['f_email'])) { echo htmlspecialchars($_SESSION['form_data']['f_email']);}?>
' /><br />
<hr>
<div>
<label>Validate Form:</label>&nbsp;&nbsp;<img src="randomImage.php"/>
<a href><img src="album/refresh.jpg" img style="border:0;" onclick="history.go()" alt="Get new Code" /></a>&nbsp;&nbsp;
<input type="text" name="visitorcode" size="5" />
</div>
<input type="submit" name="submitbutton" id="submitbutton" value="Send the Website Link to my Friend" />
</form>

djr33
09-15-2011, 12:13 AM
I don't see anything in that that would cause any errors. There isn't anything that would vary by browser either.

The only thing that looks strange is that your text type inputs consist of multiple lines with the default value like that. You should really put the value on a single line:


<input type="text" value="like this">

<input type="text" value="
Not Like This
">

jscheuer1
09-15-2011, 01:29 PM
I agree, and that error could then be taking place on mail (line breaks and tab characters don't belong in those parameters). There is a non-fatal error in logic on process_friend.php. Even if one or more of the names and/or one or more of the email addresses fails validation, as long as the CAPTCHA is passed, the email is sent. This (if my theory is correct) allows the invalid values to get passed to mail and cause the error.

You need a test for $status == 'is_ok' in there somewhere, probably replacing the current CAPTCHA one, And the CAPTCHA test shouldn't surround the mail code, it should just be another test that adds (on failure) to the $write variable and as to whether or not the $status remains 'is_ok'.

Another issue is that, since it's never mentioned anywhere else:



if(empty($inputfields))
{ echo "<center><font face='Verdana' color='grey'><h3>Please note the following :-</h3><font face='Verdana' size='2' color=red>$write</font><center>";}

Is always true. But that content should only be echoed if there is a problem.

process_friend.php

<?php
// never forget to start the session
session_start();
$_SESSION['form_data'] = $_POST;
?>


<html>
<head><title>Friend Link Processor</title></head>
<body>
<?php
//////////////VAIRABLES STORED HERE///////////////////////////////////////////////////////////////
$visitorcode=$_POST['visitorcode'];// VALIDATE CODE //
$status="is_ok";
$write="";
$m_name=$_POST['m_name']; $m_email=$_POST['m_email'];$f_name=$_POST['f_name'];$f_email=$_POST['f_email'];
///////////////////////////////////////COMMENCE FORM VALIDATION/////////////////////////////////////
/////////////////////STEP ONE VALIDATES THAT MY NAME IS ENTERED/////////////////////////////////////
if (strlen($m_name) <2 ) { $write.="Please enter your Name<BR />";$status="not_ok";}
////////////////////STEP TWO VALIDATES THAT MY CORRECT EMAIL ADDRESS IS USED////////////////////////
/////////////if (preg_match('/http:/', $notes))
if (!preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^", $m_email))
{ $write.="Your email address is not correct!<BR />"; $status="not_ok";}
/////////////////STEP THREE VALIDATES THAT FRIENDS NAME ENTERED/////////////////////////////////////
if (strlen($f_name) <2 ) { $write.="Please enter your Friend's Name<BR />"; $status="not_ok";}
//////////////////STEP FOUR VALIDATES MY FRIENDS EMAIL///////////////////////////////////////////////
if (!preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^", $f_email))
{ $write.="Your Friends email address is not correct!<BR />"; $status="not_ok";}
///////////////////STEP FIVE VALIDATES NUMBER OF EMAIL ADDRESSES USED/////////////////////////////////
if(substr_count($m_email,"@") > 1 or substr_count($f_email,"@") > 1)
{ $write.="Use only one email address please<BR />";$status="not_ok";}
if(empty($visitorcode))
{ $write.="Do not forget to fill out the <b>VALIDATE</b> code!<BR />";$status="not_ok";}
/////////////////Captcha Validation to block Spambots//////////////////////////////////////////////////////
if (md5($visitorcode) !== $_SESSION['image_random_value'])
{ $write.="<br /><font face='Verdana' size='2' color=blue>Your message was not sent because you entered the invalid letters - <b>$visitorcode</b><br />Please note that the letters are case sensitive. </font><BR />";
$status="not_ok"; }
if(!empty($write))
{ echo "<center><font face='Verdana' color='grey'><h3>Please note the following :-</h3><font face='Verdana' size='2' color=red>$write</font><center>";
echo '<br /><form action="form_friend.php"><input type="submit" value="Go Back to Form"></form>';
die();}

/* echo "<h2>Code $visitorcode valid </h2>\n"; */
///////////////////////////// INSTALL MESSAGE HERE ////////////////////////////////////////////////////
$header_message="Hi $f_name , \n\nYour friend $m_name invites you to visit Website at www.webitry.net \n\nYou can view a eCommerce Shopping Demonstration just to see how easy it is to sell online. \n\nIf you or any of your friends would like to sell online just contact the Webitry and discuss your requirement. They will be delighted to hear from you.\n\nHave a nice day!";

$body_message=$header_message."\n";
//// MAIL POSTING STARTS HERE /////////
$headers="";
//$headers="Content-Type: text/html; charset=iso-8859-1\n".$headers;
// Un comment the above line to send mail in html format
$headers4=$m_email; // Change this to change from address
$headers.="Reply-to: $headers4\n";
$headers.="From: $headers4\n";
$headers.="Errors-to: $headers4\n";
$subject="$m_name - Invitation to visit Website";
mail($f_email,$subject,$body_message,$headers);
///////////////////// END OF POSTING /////////////// & PRESENTING THANK YOU PAGE /////////////////////
echo "<center><font face='Verdana' size='3' color=green><br />Thank You, <br /><br />You sent a link for this Website to your friend $f_name. This is a great help to us. Your assistance is much appreciated.<br /><h3>The Webmaster.</h3></font></center>";

?>
</body>
</html>

The Form:

<form method="post" action="process_friend.php">
<legend>Send Website Link to my Friend.</legend><br />
<label>My Name: </label><input type='text' id="textfield" name='m_name'
value='<?php if(isset($_SESSION['form_data']['m_name'])) { echo htmlspecialchars($_SESSION['form_data']['m_name']);}?>' /><br />
<label>My Email: </label><input type='text' id="textfield" name='m_email'
value='<?php if(isset($_SESSION['form_data']['m_email'])) { echo htmlspecialchars($_SESSION['form_data']['m_email']);}?>' /><br />
<label>Friend's Name: </label><input type='text' id="textfield" name='f_name'
value='<?php if(isset($_SESSION['form_data']['f_name'])) { echo htmlspecialchars($_SESSION['form_data']['f_name']);}?>' /><br />
<label>Friend's Email: </label><input type='text' id="textfield" name='f_email'
value='<?php if(isset($_SESSION['form_data']['f_email'])) { echo htmlspecialchars($_SESSION['form_data']['f_email']);}?>' /><br />
<hr>
<div>
<label>Validate Form:</label>&nbsp;&nbsp;<img src="randomImage.php"/>
<a href><img src="album/refresh.jpg" img style="border:0;" onclick="history.go()" alt="Get new Code" /></a>&nbsp;&nbsp;
<input type="text" name="visitorcode" size="5" />
</div>
<input type="submit" name="submitbutton" id="submitbutton" value="Send the Website Link to my Friend" />
</form>

Note: The form page should probably have (if it doesn't already):


<?php
// never forget to start the session
session_start();
?>

at the beginning.

Webiter
09-15-2011, 06:29 PM
Hi Guys, Update on status further to your comments and alterations.

Firefox = Working as required
IE = Working as required
Chrome = Now indicating 'My Email' not correct even though email is entered correctly in field ! :confused:
Safari = Now indicating 'My Email' and 'Friend Email' not correct even though they are entered correctly in fields ! :confused: :confused:

I cannot figure out why email validation can be working fine when using Firefox and IE and not working to requirement in Chrome and Safari ?

jscheuer1
09-15-2011, 11:14 PM
I just tested your site in Safari 5.1 Win 7 with:

bob
bob@bob.com
ted
ted@ted.com

And it worked fine. What kind of information are you putting in that gives you an error?

Before you answer that, make sure to clear the browser's cache and refresh the form_friend.php page in the popup. It might be working from a previously cached version.

Webiter
09-16-2011, 03:15 PM
Oops, sorry. Cleared the cache and all seems to be working fine now. Thanks for the assistance guys. :)