Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

PHP script conflicts with JavaScript and crashed IE5.5

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

PHP script conflicts with JavaScript and crashed IE5.5

Postby sametch » Mon May 12, 2003 5:00 am

I have written a form in PHP which also has a JavaScript function for centring the form on the page (function called CentreWebDesign).

The form itself works fine when I don't make a call to the function CentreWeb Design. Likewise the function works fine in other (non form) PHP pages.

But when I use the function with the form. IE 5.5 crashes and AOL 7 the page shuts down. (IE 5, 6 Opera 5 to 7 Netscape 6-7 are all fine)

I've spent ages trying to get to the bottom if it but I can't see it.

Can anyone help?

function and code below:


<html>
<head>

<title>page title</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript" src="c.js"></script>
<link href="content.css" rel="stylesheet" type="text/css">

<meta name="description" content="">
<meta name="keywords" content="">
<?php
$emailmessage="";
$datafield="";
$datain="";
$errormsg="";

foreach ($HTTP_POST_VARS as $key=>$value)
{
$$key = stripslashes(removeHTML($value));

if (!($key == "Submit"))
{

switch ($key)
{
case "fn":
if (empty($value) || $value == " ") $errormsg = $errormsg."The First Name field has been left blank. Please enter a First Name. <br>";
break;
case "ln":
if (empty($value) || $value == " ") $errormsg = $errormsg."The Last Name field has been left blank. Please enter a Last Name. <br>";
break;
case "company":
if (empty($value) || $value == " ") $errormsg = $errormsg."The Company field has been left blank. Please enter a Company or Business name. <br>";
break;
case "tel":
if (empty($value) || $value == " ") $errormsg = $errormsg."The Telephone field has been left blank. Please enter a Telephone number. <br>";
break;
case "email":
if (!empty($value) && !(EmailCheck($value) == "ok")) $errormsg = $errormsg.EmailCheck($value);
break;
case "requirements":
if (empty($value) || $value == " ") $errormsg = $errormsg."You have not specified your requirements, the more information you provide to us, the more likely we are to be able to help you. <br>";
break;
}

if (!empty($value))
{
$emailmessage = $emailmessage . "$key = ".stripslashes(removeHTML($value))." \n";
$datafield = $datafield . "$key, ";
$datain = $datain . "'".stripslashes(removeHTML($value))."', ";
}
}
}

$datafield = RemoveEndComma(rtrim($datafield));
$datain = RemoveEndComma(rtrim($datain));

?>

<style type="text/css">
<!--
#container{position: absolute; top: 15px; left: 0px}
-->
</style>
</head>
<body onLoad="CentreWebDesign(740); MM_preloadImages('images/faq-o.gif','images/contacts-o.gif','images/clients-o.gif','images/features-o.gif','images/services-o.gif','images/about-o.gif','images/home-o.gif')" onResize="CentreWebDesign(740)">
<div id="container">
<div class="heading">
<?
if (isset($stage) && ($stage == 'process'))
{
if (empty($errormsg) || $errormsg == "")
{
echo "Thank You For Your Enquiry";
}
else
{
echo "Form Error";
}
}
else
{
echo "how to contact us";
}
?>
</div>
<div class="content">
<?php
function removeHTML($text)
{
$text=str_replace('"',""",$text);
$text=str_replace("'","'",$text);
$text = strip_tags($text, '<b><i><u><br>,<br />');
return $text;
}
function RemoveEndComma($string)
{
if (substr($string,-1) == ",")
{
$string = substr($string,0,(strlen($string)-1));
}
return $string;
}

function EmailCheck($string)
{
$at = false;
$dot = false;
for ($i = 0, $j = strlen($string); $i < $j; $i++)
{
if (strstr('@',$string[$i])) $at = true;
if (strstr('.',$string[$i])) $dot = true;
}
if ($at && $dot)
{
return "ok";
}
else
{
return "The email address entered is not in a recognised format, please re-enter.<br>";
}
}

function freshpage()
{
echo "<p><span class=\"inline-h\">Address:</span><br>\n";
echo "one<br>\n";
echo "two<br>\n";
echo "three<br>\n";
echo "four<br>\n";
echo "five<br>\n";
echo "six<br>\n";
echo "<span class=\"inline-h\">Tel/Fax:</span><br>\n";
echo "t: 999999999<br>\n";
echo "f: 999999999</p>\n";
echo "<p><span class=\"inline-h\">Company Details:</span><br>\n";
echo "<br>\n";
echo "none\n";
echo "none</p>\n";
echo "<p><span class=\"inline-h\">Enquiries:</span><br>\n";
echo "If you have an enquiry or would like our assistance, either contact us using\n";
echo "one of the methods above or complete the enquiry form below:</p>\n";
echo "<form name=\"form1\" method=\"post\" action=\"$_SERVER[PHP_SELF]\">\n";
echo "<table width=\"670\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"5\" summary=\"Enquiry Form\">\n";
echo "<tr>\n";
echo "<td width=\"158\"><p class=\"formtext\">First Name</p></td>\n";
echo "<td width=\"169\"><input name=\"fn\" type=\"text\" id=\"fn\" style=\"background-color: #F5FAE6; color: #00773C; border: 1 solid #3FBE7B; font-family: Arial, Helvetica, sans-serif; font-size: 10pt;\" size=\"18\"></td>\n";
echo "<td colspan=\"2\"><p class=\"formtext\"><strong>Do you have specific requirements?</strong></p></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><p class=\"formtext\">Last Name</p></td>\n";
echo "<td><input name=\"ln\" type=\"text\" id=\"ln\" style=\"background-color: #F5FAE6; color: #00773C; border: 1 solid #3FBE7B; font-family: Arial, Helvetica, sans-serif; font-size: 10pt;\" size=\"18\"></td>\n";
echo "<td width=\"22\"><input type=\"checkbox\" name=\"ecommerce\" value=\"checkbox\" id=\"ecommerce\" style=\"background-color: #F5FAE6; color: #00773C; border: 1 solid #3FBE7B; font-family: Arial, Helvetica, sans-serif; font-size: 10pt;\"></td>\n";
echo "<td width=\"296\"><p class=\"formtext\">e-commerce</p></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><p class=\"formtext\">Company</p></td>\n";
echo "<td><input name=\"company\" type=\"text\" id=\"company\" style=\"background-color: #F5FAE6; color: #00773C; border: 1 solid #3FBE7B; font-family: Arial, Helvetica, sans-serif; font-size: 10pt;\" size=\"22\"></td>\n";
echo "<td><input type=\"checkbox\" name=\"contentmgmt\" value=\"checkbox\" id=\"contentmgmt\" style=\"background-color: #F5FAE6; color: #00773C; border: 1 solid #3FBE7B; font-family: Arial, Helvetica, sans-serif; font-size: 10pt;\"></td>\n";
echo "<td><p class=\"formtext\">content management websites</p></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><p class=\"formtext\">Tel</p></td>\n";
echo "<td><input name=\"tel\" type=\"text\" id=\"tel\" style=\"background-color: #F5FAE6; color: #00773C; border: 1 solid #3FBE7B; font-family: Arial, Helvetica, sans-serif; font-size: 10pt;\" size=\"14\"></td>\n";
echo "<td><input type=\"checkbox\" name=\"language\" value=\"checkbox\" id=\"language\" style=\"background-color: #F5FAE6; color: #00773C; border: 1 solid #3FBE7B; font-family: Arial, Helvetica, sans-serif; font-size: 10pt;\"></td>\n";
echo "<td><p class=\"formtext\">multi-language websites</p></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><p class=\"formtext\">Email</p></td>\n";
echo "<td><input name=\"email\" type=\"text\" id=\"email\" style=\"background-color: #F5FAE6; color: #00773C; border: 1 solid #3FBE7B; font-family: Arial, Helvetica, sans-serif; font-size: 10pt;\" size=\"22\"></td>\n";
echo "<td><input type=\"checkbox\" name=\"ezine\" value=\"checkbox\" id=\"ezine\" style=\"background-color: #F5FAE6; color: #00773C; border: 1 solid #3FBE7B; font-family: Arial, Helvetica, sans-serif; font-size: 10pt;\"></td>\n";
echo "<td><p class=\"formtext\">please keep me updated on offers and news</p></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><p class=\"formtext\">Your Requirements</p></td>\n";
echo "<td colspan=\"3\"><label for=\"textarea\"></label>\n";
echo "<textarea name=\"requirements\" id=\"requirements\"></textarea></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td colspan=\"4\" align=\"center\"><input type=\"submit\" name=\"Submit\" value=\"Submit\" id=\"Submit\" style=\"background-color: #DEEFAD; color: #336633; border: 1 solid #3FBE7B;\">\n";
echo "<input type=\"hidden\" name=\"stage\" value=\"process\">";
echo "<input type=\"reset\" name=\"Reset\" value=\" Reset\" id=\"label\" style=\"background-color: #DEEFAD; color: #336633; border: 1 solid #3FBE7B;\"></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</form>\n";
echo "<p><span class=\"inline-h\">How we use the information you provide:</span><br>\n";
echo "Your details will be used to enable us to make contact with you to answer\n";
echo "your enquiry. Your details will not be given or sold to any third party.\n";
echo "If you tick the email box, you will receive periodic emails with offers and news.\n";
echo "You can unsubscribe at any time, we are not into annoying people.<br>\n";
echo "</p>";
}

if (isset($stage) && ($stage == 'process'))
{
if (empty($errormsg) || $errormsg == "")
{

$mail_to = "aa@aaaa.aa";
$mail_subject = "";
$mail_body = $emailmessage;

if(mail($mail_to, $mail_subject, $mail_body))
{
echo "<p>Your enquiry has been successfully processed. We will be contacting you shortly</p>";
}
else
{
echo "<p><b>email failed to send, please contact us on <a href=\"mailto:aa@aaaa.aa\">aa@aaaa.aa</a></b></p>";
}
}
else
{
echo "<h1>There is an error in the form. Please see the points below:</h1>";
echo "<p>$errormsg</p>";
}
}
else
{
freshpage();
}


?>
<img src="images/bottom.gif" width="720" height="78" alt="Copyright "></div>
<div class="b-faq"><a href="faq.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('faq','','images/faq-o.gif',1)"><img src="images/faq.gif" alt="frequently asked questions" name="faq" width="46" height="29" border="0"></a></div>
<div class="b-clients"><a href="clients.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('clients','','images/clients-o.gif',1)"><img src="images/clients.gif" alt="example clients" name="clients" width="55" height="26" border="0"></a></div>
<div class="b-contacts"><a href="contact.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('contact','','images/contacts-o.gif',1)"><img src="images/contacts.gif" alt="contact us" name="contact" width="68" height="26" border="0"></a></div>
<div class="b-features"><a href="features.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('features','','images/features-o.gif',1)"><img src="images/features.gif" alt="features of our sites" name="features" width="66" height="26" border="0"></a></div>
<div class="b-services"><a href="services.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('services','','images/services-o.gif',1)"><img src="images/services.gif" alt="Services we offer" name="services" width="67" height="26" border="0"></a></div>
<div class="b-about"><a href="about.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('about','','images/about-o.gif',1)"><img src="images/about.gif" alt="about affordable e-commerce" name="about" width="52" height="26" border="0"></a></div>
<div class="b-home"><a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('home','','images/home-o.gif',1)"><img src="images/home.gif" alt="homepage" name="home" width="50" height="26" border="0"></a></div>
<div class="top"><img src="images/top.gif" width="720" height="145" alt="affordable ecommerce"></div>
</div>
</body>
</html>

**Javacript file**

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function CentreWebDesign(DesignWidth)
{
var LeftStart=0;
var PageSize=0;
if (document.body.clientWidth != null)
{
PageSize=document.body.clientWidth;
}
else
{
if (window.innerWidth != null)
{
PageSize=document.innerWidth;
}
}
if (PageSize > DesignWidth)
{
LeftStart=Math.round((PageSize - DesignWidth)/2);
}
document.getElementById('container').style.left = LeftStart;
}
sametch
New php-forum User
New php-forum User
 
Posts: 17
Joined: Wed Jul 03, 2002 3:10 am

Postby Oleg Butuzov » Mon May 12, 2003 5:34 am

i didnt find any bad word here....
but open a IE 5.0 bug (and abov)

<input type>

and IE crash
IE == "bug machine"
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher and 7 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.