[英]This doesn't works in IE bt in all other browsers
This is the code of my form这是我的表格代码
<form method="post" style="margin-left:15px;margin-top:6px;" onsubmit="return map_Email_Validation();">
<table>
<tr>
<td colspan="2" class="faceboxheading" style="white-space:nowrap;">Share your map information with your friends</td>
<td colspan="2" align="left"><a href="javascript:void(0);" class="hrf_btn" onclick="hide_facebox();">[x]</a></td>
</tr>
<tr></tr>
<?php if($error) {?>
<tr>
<td colspan="2" class="faceboxheading"><?php echo $error;?></td>
</tr>
<?php }?>
<tr>
<td width="100px">To Email</td>
<td width="250px"><input type="text" name="ToID" id="ToID" style="width:274px;" onkeyup="dis();"/></td>
</tr>
<tr>
<td>From Email</td>
<td><input type="text" name="fromID" id="fromID" style="width:274px;" onkeyup="dis();" value="'.$g['email'].'" /></td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="subject" id="subject" style="width:274px;" onkeyup="dis();"/></td>
</tr>
<tr>
<td>URL</td>
<td><input type="text" readonly="readonly" name="URL" id="URL" size="42" style="width:274px;"/></td>
</tr>
<tr>
<td>Message</td>
<td valign="top"><textarea id="message" name="message" cols="25" rows="4" style="width:274px;" onkeyup="dis();"></textarea></td>
</tr>
<tr><td></td>
<td> <input type="image" style="margin-left:-2px;" src="http://jersey.cimaps.co.uk/jersey_dev/templates/default/images/send.png" name="submitbtn" id="submitbtn" value="Send"/></td>
</td></tr>
</table>
</form>
The functions are功能是
function map_Email_Validation()
{
var ToID = document.getElementById('ToID').value;
//var fromID = document.getElementById('fromID').value;
var subject = document.getElementById('subject').value;
var message = document.getElementById('message').value;
var char_at=ToID.indexOf("@");
var char_dot=ToID.indexOf(".");
var char_dolar=ToID.indexOf("$");
var char_hash=ToID.indexOf("#");
var at="@";
var lat=ToID.indexOf(at);
if(ToID.length<1)
{
alert('Please enter To Email!');
return false;
}
else if((char_at==-1)||(char_dot==-1)||(char_dolar!=-1)||(char_hash!=-1))
{
alert( 'Invalid To Email!');
return false;
}
else if((char_at==0)||(char_dot==1)||(char_dot==char_at+1))
{
alert( 'Invalid To Email!');
return false;
}
if(subject.length<1)
{
alert( 'Please enter Subject!');
return false;
}
if(message.length<1)
{
alert( 'Please enter Message!');
return false;
}
else if(message.length>100)
{
alert( 'Message can have only 100 characters!');
return false;
}
return true;
}
code in index page is
if(isset($_POST['submitbtn']))
{
//echo "set";
$flag=true;
$error="";
/*Getting Values**********************/
$ToID=$_POST['ToID'];
$fromID=$_POST['fromID'];
$subject=$_POST['subject'];
$URL=$_POST['URL'];
$message=$_POST['message'];
/*Validating the data*****************/
if(strlen($ToID)==0)
{
$flag=false;
$error.="Enter To email address field";
}
elseif(!preg_match_all("|^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$|U",$ToID,$arr))
{
$flag=false;
$error.="Invalid To email address";
}
if(strlen($subject)==0)
{
$flag=false;
$error.="Enter subject field";
}
if(strlen($message)==0)
{
$flag=false;
$error.="Enter message field";
}
elseif(strlen($message)>100)
{
$flag=false;
$error.="Message can have only 100 charaters";
}
if($flag=="true")
{
$urltoemail = "<html><head><title>Forgot Password</title></head><body>
<table><tr><td>".$message."</td></tr><tr><td><a href='{$URL}'>Click here for viewing map</a></td></tr></table></body></html>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
if(strlen($fromID)==0)
$fromID = 'info@cimaps.co.uk';
$headers .= "From: $fromID \r\n";
mail($ToID,$subject,$urltoemail,$headers);
//header("Location:".$_SERVER['SCRIPT_NAME']);
}
}
The mail doesnot sent in IE but successfully in all other browsers..Any idea?邮件没有在 IE 中发送,但在所有其他浏览器中成功发送。知道吗?
It's really hard to read your code and determine what you are asking.阅读您的代码并确定您要问什么真的很困难。
However, since mail is not a client-side activity, this is almost certainly an issue with whatever is being sent to the server (ie in the POST).然而,由于邮件不是客户端活动,这几乎肯定是发送到服务器的任何内容(即在 POST 中)的问题。 Try putting a breakpoint in your code when the page's POST is first received and compare the POST values from IE to Chrome/Firefox.尝试在第一次收到页面的 POST 时在代码中设置断点,并比较 IE 和 Chrome/Firefox 的 POST 值。 I'm guessing you'll see that they are different and can quickly fix it.我猜你会发现它们是不同的,并且可以快速修复它。
Update - what if you try doing this instead of looking for the named submit:更新- 如果您尝试这样做而不是寻找命名提交怎么办:
if (!empty($_POST))
I'm not sure and I don't fully understand the fix that you had made.我不确定,也不完全理解您所做的修复。 But for me, the check if(isset($_POST['submitbtn']))
fails in both IE8 and FF4;但对我来说,检查if(isset($_POST['submitbtn']))
在 IE8 和 FF4 中都失败了; it worked fine in Chrome12.它在 Chrome12 中运行良好。 And the reason is that when you are using an <input type="image">
kind of button to submit the form, you need to check it like this:原因是当您使用<input type="image">
类型的按钮提交表单时,您需要像这样检查它:
if(isset($_POST['submitbtn_x'])) {
...
...
}
And that check will work on all browsers.该检查将适用于所有浏览器。 To check this, you may like to do a print_r($_POST)
just before where the if() starts and see how it looks like.要检查这一点,您可能希望在 if() 开始之前执行print_r($_POST)
并查看它的外观。
Hope this helps to solve your problem.希望这有助于解决您的问题。
/Abhay /阿拜
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.