我需要将一些参数从php页面发送到另一个页面来动态地发送电子邮件,
如果我以硬编码的方式发送值是可以的,但是如果我将值发送到文本字段,它就不起作用了,
这里的代码
要求邮寄邮件的网页
<script>
$otroYa = other.val();
console.log (other.val()); //shows value ok of this var!
$.post( "send-mail-parklane-suscrib.php" , {otro: "ss9", otro2: $otroYa });
</script>
所以,
otro2 = $otroYa
没有设定?,但硬编码的otro,是可以的
调用php页面执行post
<html>
<head><title>PHP Mail Sender</title></head>
<body>
<?php
session_start();
echo("chamb");
$to = 'juanma@gmail.com';
$from = 'bot@prklanefinancial.com.au';
$subject = 'Prklane Financial Subscribe';
$headers = 'From: bot@prklanefinancial.com.au' . "\r\n".
'Reply-To: test@abc.com'. "\r\n".
'Return-Path: test@abc.com' . "\r\n".
'X-Mailer: PHP/' . phpversion();
$message = "SS9 tkt ss9!!!";
$name=$_POST['otro2'];
mail($to, $subject, $name, $headers, "-f $from");
?>
</body>
</html>
所以如果我把我的邮件
$name=$_POST'otro2';
是空的
但是使用硬编码
$name=$POST‘’otro‘;
可以吗?
如何设置变量?
谢谢!
发布于 2013-10-20 01:17:55
您将PHP和JavaScript混为一谈。
而不是
$otroYa = other.val();
它应该是:
var otroYa = other.val();
jquery post请求应该是:
$.post( "send-mail-parklane-suscrib.php" , {otro: "ss9", otro2: otroYa });
https://stackoverflow.com/questions/19472873
复制相似问题