Php表单在特定服务器上不起作用
我有一个使用php脚本的表单,它在其他服务器上运行良好,但是我在实时服务器上遇到了问题。以下我已提及详情: 使用ajax调用和php发送联系人表单。它在我检查过的两台服务器上工作,其中一台链接在下面 但是,当我将同一表单上传到live server时,它不工作,我不知道为什么??:(现场直播链接如下: php安装在服务器上,如果服务器中关闭了任何必要的东西,请告知我,以下是php信息链接: 以下是php代码Php表单在特定服务器上不起作用,php,javascript,jquery,Php,Javascript,Jquery,我有一个使用php脚本的表单,它在其他服务器上运行良好,但是我在实时服务器上遇到了问题。以下我已提及详情: 使用ajax调用和php发送联系人表单。它在我检查过的两台服务器上工作,其中一台链接在下面 但是,当我将同一表单上传到live server时,它不工作,我不知道为什么??:(现场直播链接如下: php安装在服务器上,如果服务器中关闭了任何必要的东西,请告知我,以下是php信息链接: 以下是php代码 <?php // Change this with your blog n
<?php
// Change this with your blog name and email address
$the_blogname = 'MobilityApp';
$the_myemail = 'info@urban-spot.co.uk';
if(isset($_POST['email'])){
error_reporting(0);
$errorC = false;
$the_email = $_POST['email'];
$the_name = $_POST['yourname'];
$the_message = $_POST['message'];
$the_phone = $_POST['phone'];
$the_fax = $_POST['fax'];
$the_company = $_POST['company'];
$the_website = $_POST['website'];
# want to add aditional fields? just add them to the form in template_contact.php,
# you dont have to edit this file
//added fields that are not set explicit like the once above are combined and added before the actual message
$already_used = array('email','yourname','message','phone','fax','company','website','myblogname','tempcode','temp_url','ajax');
$attach = '';
foreach ($_POST as $key => $field)
{
if(!in_array($key,$already_used))
{
$attach.= $key.": ".$field."<br /> \n";
}
}
$attach.= "<br /> \n";
if(!checkmymail($the_email))
{
$errorC = true;
$the_emailclass = "error";
}else{
$the_emailclass = "valid";
}
if($the_message == "")
{
$errorC = true;
$the_messageclass = "error";
}else{
$the_messageclass = "valid";
}
if($errorC == false)
{
$to = $the_myemail;
$subject = "New Message from " . $the_blogname;
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$header .= 'From:'. $the_email . " \r\n";
$message1 = nl2br($the_message);
if(!empty($the_name)) $the_name = "Name: $the_name <br/>";
if(!empty($the_company)) $the_company = "Company: $the_company <br/>";
if(!empty($the_phone)) $the_phone = "Phone: $the_phone <br/>";
if(!empty($the_fax)) $the_fax = "Fax: $the_fax <br/>";
if(!empty($the_website)) $the_website = "Website: $the_website <br/>";
$message = "
You have a new message! <br/>
$the_name
$the_company
$the_phone
$the_website
$attach <br />
Message: $message1 <br />";
if(@mail($to,$subject,$message,$header)) $send = true; else $send = false;
if(isset($_POST['ajax'])){
if ($send)
echo '<h3><img src="images/icon_check.png"> Your message has been sent!</h3><div class="confirm">
</div>';
else
echo '<h3>Oops!</h3><div class="confirm">
<p class="texterror">Due to an unknown error, your form was not submitted, please resubmit it or try later.</p>
</div>';
}
}
}
function checkmymail($mailadresse){
$email_flag=preg_match("!^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z] {2,4}$!",$mailadresse);
return $email_flag;
}
?>
它在某些服务器上运行,但在其他服务器上运行,这一事实让我认为它不是有问题的代码。您参考了问题服务器的phpinfo页面,但是否将其与其中一个工作服务器的phpinfo页面进行了比较?您可能正在运行不同版本的PHP。还可以检查工作服务器上的PHP.ini文件d不工作的服务器,以验证是否加载了所有正确的扩展。您需要确保启用了错误报告,并检查live PHP站点上的错误日志。您尚未发布任何PHP代码,但常见的问题是旧的PHP版本,导致新语法的分析错误,或者更常见的是@MichaelBerkowski phpcode很好&在其他服务器上工作,但是让我编辑我的问题并粘贴我的php代码。出于安全原因,在这个网站上发布你的phpInfo
链接是一个非常糟糕的主意。如果是我,我会移动itI的位置。我打赌mailto失败:If(@mail($to,$subject,$message,$header))
@user202196正如您不断重复的那样,您的代码已经在您的开发服务器上运行了。我只想告诉您,两个服务器设置几乎从来都不相同。还有什么是“不工作”呢?您自己没有发布任何错误消息或错误描述。很酷,现在它正在工作,我请服务器管理员匹配设置。
function tfuse_form1(){
var my_error;
var url = jQuery("input[name=temp_url]").attr('value');
jQuery(".ajax_form #send").bind("click", function(){
my_error = false;
jQuery(".ajax_form input, .ajax_form textarea, .ajax_form radio, .ajax_form select").each(function(i)
{
var surrounding_element = jQuery(this);
var value = jQuery(this).attr("value");
var check_for = jQuery(this).attr("id");
var required = jQuery(this).hasClass("required");
if(check_for == "email"){
surrounding_element.removeClass("error valid");
baseclases = surrounding_element.attr("class");
if(!value.match(/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/)){
surrounding_element.attr("class",baseclases).addClass("error");
my_error = true;
}else{
surrounding_element.attr("class",baseclases).addClass("valid");
}
}
if(check_for == "name" || check_for == "message"){
surrounding_element.removeClass("error valid");
baseclases = surrounding_element.attr("class");
if(value == "" || value == 'Name (required)' || value == 'Type your message' ){
surrounding_element.attr("class",baseclases).addClass("error");
my_error = true;
}else{
surrounding_element.attr("class",baseclases).addClass("valid");
}
}
if(required && check_for != "name" && check_for != "email" && check_for != "message"){
surrounding_element.removeClass("error valid");
baseclases = surrounding_element.attr("class");
if(value == ""){
surrounding_element.attr("class",baseclases).addClass("error");
my_error = true;
}else{
surrounding_element.attr("class",baseclases).addClass("valid");
}
}
if(jQuery(".ajax_form input, .ajax_form textarea, .ajax_form radio, .ajax_form select").length == i+1){
if(my_error == false){
jQuery(".ajax_form").slideUp(400);
var $datastring = "ajax=true";
jQuery(".ajax_form input, .ajax_form textarea, .ajax_form radio, .ajax_form select").each(function(i)
{
var $name = jQuery(this).attr('name');
var $value = encodeURIComponent(jQuery(this).attr('value'));
$datastring = $datastring + "&" + $name + "=" + $value;
});
jQuery(".ajax_form #send").fadeOut(100);
jQuery.ajax({
type: "POST",
url: "./sendmail.php",
data: $datastring,
success: function(response){
jQuery(".ajax_form").before("<div class='ajaxresponse'></div>");
jQuery(".ajaxresponse").html(response).slideDown(400);
jQuery(".ajax_form #send").fadeIn(400);
jQuery(".ajax_form input, .ajax_form textarea, .ajax_form radio, .ajax_form select").val("");
}
});
}
}
});
return false;
});
}