[英]php jquery send post parameters to other php page
Im new to web technology, and im having a few roadblocks, 我是网络技术的新手,并且遇到了一些障碍,
I have a php page that sends post mail request in a JS by calling another php page, 我有一个php页面,它通过调用另一个php页面在JS中发送邮件请求,
but I need to pass to that new php page the values for my mail, all works fine with hardcoded vals, but I need to know how to pass the parameters to my php send mail page, 但是我需要将我的邮件的值传递给该新的php页面,所有值都可以与硬编码的val一起正常使用,但是我需要知道如何将参数传递给我的php send mail页面,
here the code for the main php page: 这里的主要PHP页面的代码:
<script>
...
$.post( "send-mail-parklane-suscrib.php" , { name: "John", time: "2pm" });
...
</script>
and here the code for the send-mail-parklane-suscrib.php 这是send-mail-parklane-suscrib.php的代码
<html>
<head><title>PHP Mail Sender</title></head>
<body>
<?php
session_start();
echo("chamb");
$to = 'juanss234@gmail.com';
$from = 'bot@parklanefinancial.com.au';
$subject = 'Parklane Financial Subscribe';
$headers = 'From: bot@parklanefinancial.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!!!";
mail($to, $subject, $message, $headers, "-f $from");
?>
</body>
</html>
so how to access this vals on my send mail page? 那么如何在我的发送邮件页面上访问此Val?
thanks! 谢谢!
They'll be saved into a superglobal
, $_POST
. 它们将保存到
superglobal
$_POST
。
<?php
echo $_POST["name"]; //Echos John
echo $_POST["time"]; //Echo 2pm
/**
* You may see at anytime if your page has
* any set by: (Dev use only) Printing the contents
* of the $_POST Array.
**/
print_r( $_POST );
/**
* Note, it's important you check the existence
* & verify any values sent.
**/
if ( isset( $_POST["name"] ) && $_POST["name"] !== '' ) {
//Code
$Name = $_POST["name"];
}
?>
There are others too: 还有其他一些:
$_GET
- For GET Requests $_GET
用于GET请求 $_POST
- For POST Requests $_POST
用于POST请求 $_COOKIE
- For Cookies $_COOKIE
对于Cookie $_REQUEST
- For All of the Above. $_REQUEST
以上所有。 Use $_POST
使用
$_POST
$name=$_POST['name'] //John
etc., 等等。,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.