第一次用PHP
主要是些个PAYPAL的IPN我用VC对用户名进行了 MD5计算, 计算结果和这个网址的计算结果一样
http://www.toolw.cn/md5/但是下面这个PHP程序里面, 计算的结果却不同,
肯定是编码的问题, 但是我不知道的PHP程序错在哪里,
请大家帮忙看看, 谢谢//PHP程序: PAYPAL付款后,发送到我这个PHP程序, 然后我计算用户名的MD5值.
<?php
header ('Content-type: text/html; charset=utf-8');
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
///////////////////////////////////////////////////////foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
///////////////////////////////////////////////
// Prepare posting to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);$payer_firstname = $_POST['first_name'];
$payer_lastname = $_POST['last_name'];
/////////////////////////////////////////////////////////////////////
// This is the part that actually sends the validation back to PayPal
if (!$fp)
{
echo("出错了");
}
else
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
//MD5(用户名)
$szLicenseUser= $payer_firstname.$payer_lastname;
echo( strtoupper(md5($szLicenseUser))); }
else if (strcmp ($res, "INVALID") == 0)
{
echo("出错了");
}
}
fclose ($fp);
}
?>
主要是些个PAYPAL的IPN我用VC对用户名进行了 MD5计算, 计算结果和这个网址的计算结果一样
http://www.toolw.cn/md5/但是下面这个PHP程序里面, 计算的结果却不同,
肯定是编码的问题, 但是我不知道的PHP程序错在哪里,
请大家帮忙看看, 谢谢//PHP程序: PAYPAL付款后,发送到我这个PHP程序, 然后我计算用户名的MD5值.
<?php
header ('Content-type: text/html; charset=utf-8');
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
///////////////////////////////////////////////////////foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
///////////////////////////////////////////////
// Prepare posting to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);$payer_firstname = $_POST['first_name'];
$payer_lastname = $_POST['last_name'];
/////////////////////////////////////////////////////////////////////
// This is the part that actually sends the validation back to PayPal
if (!$fp)
{
echo("出错了");
}
else
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
//MD5(用户名)
$szLicenseUser= $payer_firstname.$payer_lastname;
echo( strtoupper(md5($szLicenseUser))); }
else if (strcmp ($res, "INVALID") == 0)
{
echo("出错了");
}
}
fclose ($fp);
}
?>
解决方案 »
- 敢问高手这些是如何实现的?(我就不信我发不成功)
- PHP菜鸟求助
- 网上下的模板运行报错
- 关联数组怎么排序
- 如果通过URL传递阵列的值???
- 请大家推荐一个PHP+MYSQL的收费空间吧。
- PHP输出问题?急!!!
- 急救问题:php连接sqlserver2000中怎样上传文件存储在数据库中?
- 我在win2000上用php的session功能出错,抱不能写入目录的错误.但是在unix机上又是好的,是不是win2000的目录权限问题?
- 关于php触发器跟处理器的一些小问题,谢谢!
- 我用一个form来post一个参数“/3/1/"去另一个页面,但用$_REQUEST获取不到
- Zend Studio7远程调试问题,还有一个很神奇的防火墙访问PHP问题
而你上面的程序,可能不是,所以,结果一定是不样的!
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
那我怎么知道我的页面该用哪种编码呢?用户名可能有中文 英文 阿拉伯 世界各种语言, 我应该用UTF-8吧?
而php代码中却用utf-8 ....header ('Content-type: text/html; charset=utf-8');
---------------------------------------------------gb2312这个只支持中文
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>MD5在线查询 MD5在线加密 MD5在线计算 www.toolw.cn</title>
<meta name="keywords" content=" MD5在线加密 MD5在线解密" />
<meta name="description" content="MD5在线查询 MD5在线加密 MD5在线计算"
<link href="md5.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function show(n_s){
//document.getElementById('s_md5').innerHTML='<iframe marginheight=0 marginwidth=0 scrolling="no" frameborder="0" width="760" height="80" src="md5.php?n_s="'+n_s+'></iframe>';
document.getElementById('s_md5').innerHTML='<font color=red>正在查询...</font>';
document.getElementById('s_md5').innerHTML='<iframe marginheight=0 marginwidth=0 scrolling="no" frameborder="0" width="450" height="92" src="md5.php?n_s='+n_s+'"></iframe>';
}
</script>
</head><body>
<center>
<br><br>
<h1>MD5在线查询</h1>
<div id="src" style="margin:auto;">请输入欲查询的值:<input name="n_s" type="text" onkeyup='show(this.value)'></div>
<div id="s_md5"></div>
</center>
</body>
</html>
VC程序用的 UNICODE的W版本. 也要换成UTF-8