功能半工作 [英] Function half working

查看:75
本文介绍了功能半工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与PHP一起发送电子邮件的功能。它做到了。 id不做的是隐藏表单并说谢谢。

I have a function that in conjunction with PHP sends an email. It does that. What id doesn't do is hide the form and say Thanks.

<pre><script>
$(function() {
  $("#myform").on('submit', function(e) {
    e.preventDefault();
    $.ajax({
      url: 'send_mail.php',
      dataType: 'json',
      data: $("#myform").serialize()
    }).done(function(d) {
      if (d.success==true) {
        $("#myform").hide();
        $("#results").text("Thanks!").show();
      }
    });
  });
});
</script>>










<pre><?php

$webmaster_email = "ds@mediascrubber.com";
$email_address = $_REQUEST['email_address'] ;

function isInjected($str) {
	$injections = array('(\n+)',
	'(\r+)',
	'(\t+)',
	'(%0A+)',
	'(%0D+)',
	'(%08+)',
	'(%09+)'
	);
	$inject = join('|', $injections);
	$inject = '/$inject/i';
	if(preg_match($inject,$str)) {
		return true;
	}
	else {
		return false;
	}
}

if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}

elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}

else {
mail( "$webmaster_email", "Feedback Form Results", "From: $email_address" );
header('Content-Type: application/json');
echo json_encode($data);

}
?>







我尝试了什么:



我试过在PHP部分中移动json代码。




What I have tried:

I tried moving the json code around in the PHP part.

推荐答案

function (){


(< span class =code-string> #myform)。on(' submit' function (e){
e.preventDefault();
("#myform").on('submit', function(e) { e.preventDefault();


.ajax({
url:' send_mail.php'
dataType:' json'
data:
.ajax({ url: 'send_mail.php', dataType: 'json', data:


这篇关于功能半工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆