Php 重定向到贝宝支付

Php 重定向到贝宝支付,php,http,Php,Http,晚上好。我想做的是,在用户单击paypal的“buynow”按钮后,首先转到一个页面,该页面将用户购买的物品存储在数据库中,然后重定向到paypal付款 这就是我所拥有的: <?php if(isset($_POST['cmd']) && isset($_POST['hosted_button_id']) && isset($_POST['diskSpace']) && isset($_POST['bandwidth']) &&am

晚上好。我想做的是,在用户单击paypal的“buynow”按钮后,首先转到一个页面,该页面将用户购买的物品存储在数据库中,然后重定向到paypal付款

这就是我所拥有的:

<?php

if(isset($_POST['cmd']) && isset($_POST['hosted_button_id']) && isset($_POST['diskSpace']) && isset($_POST['bandwidth']) && isset($_POST['subdomains']) && isset($_POST['additionalftp']) && isset($_POST['mysqldatabases']) && isset($_POST['emailforwarding']) && isset($_POST['autoresponders']) && isset($_POST['emaildistribution']) && isset($_POST['mailboxes']) && isset($_POST['oneclick']) && isset($_POST['operatingsystem'])){

    $cmd = $_POST['cmd'];
    $custom =  md5(date("his").microtime());
    $hosted_button_id = $_POST['hosted_button_id'];

    $diskSpace = $_POST['diskSpace'];
    $bandwidth = $_POST['bandwidth'];
    $subdomains = $_POST['subdomains'];
    $additionalftp = $_POST['additionalftp'];
    $mysqldatabases = $_POST['mysqldatabases'];
    $emailforwarding = $_POST['emailforwarding'];
    $autoresponders = $_POST['autoresponders'];
    $emaildistribution = $_POST['emaildistribution'];
    $mailboxes = $_POST['mailboxes'];
    $oneclick = $_POST['oneclick'];
    $operatingsystem = $_POST['operatingsystem'];

    $con = mysql_connect('localhost', '', '');
    $db = mysql_select_db('', $con);    

    if(!mysql_query("SELECT * FROM `hostingAccounts` ORDER BY id")){
        $createTable = ("CREATE TABLE IF NOT EXISTS `hostingAccounts` (
        `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
        `ref` TEXT NOT NULL, 
        `disk_space` TEXT NOT NULL, 
        `bandwidth` TEXT NOT NULL, 
        `sub_domains` TEXT NOT NULL, 
        `additional_ftp` TEXT NOT NULL, 
        `mysql_databases` TEXT NOT NULL, 
        `email_forwarding` TEXT NOT NULL, 
        `auto_responders` TEXT NOT NULL, 
        `email_distribution` TEXT NOT NULL, 
        `mailboxes` TEXT NOT NULL, 
        `one_click_apps` TEXT NOT NULL, 
        `operating_system` TEXT NOT NULL, 
        `payer_email` TEXT NOT NULL, 
        `first_name` TEXT NOT NULL, 
        `last_name` TEXT NOT NULL, 
        `payer_id` TEXT NOT NULL, 
        `address_street` TEXT NOT NULL, 
        `address_city` TEXT NOT NULL, 
        `address_state` TEXT NOT NULL, 
        `address_zip` TEXT NOT NULL, 
        `address_country` TEXT NOT NULL
        ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;");

        mysql_query($createTable);
    } 

    mysql_query("INSERT INTO `hostingAccounts` (ref, disk_space, bandwidth, sub_domains, additional_ftp, mysql_databases, email_forwarding, auto_responders, email_distribution, mailboxes, one_click_apps,  operating_system) VALUES ('$custom', '$diskspace', '$bandwidth', '$subdomains', '$additionalftp', '$mysqldatabases', '$emailforwarding', '$autoresponders', '$emaildistribution', '$mailboxes', '$oneclick', '$operatingsystem')") or die (mysql_error());

    $host = "https://www.paypal.com";
    $path = "/cgi-bin/webscr";
    $data = "cmd=".$cmd."&hosted_button_id=".$hosted_button_id."&custom=".$custom;
    $data = urlencode($data);

    header("POST $path HTTP/1.1\r\n" );
    header("Host: $host\r\n" );
    header("Content-type: application/x-www-form-urlencoded\r\n" );
    header("Content-length: " . strlen($data) . "\r\n" );
    header("Connection: close\r\n\r\n" );
    header($data);
}
?> 
问题在于,它只是出现了内部服务器错误。有人能看出我做错了什么吗

编辑:

如果希望在脚本中发布帖子,可以尝试使用curl_*函数族

此外,您需要尝试清理客户端的输入:

$cmd = $_POST['cmd'];
另外,为什么不自己创建表呢。选择每一个请求会带来很多不必要的开销:更不用说非常不稳定了——您的代码中有您的DB模式

if(!mysql_query("SELECT * FROM `hostingAccounts` ORDER BY id")){
        $createTable = ("CREATE TABLE IF NOT EXISTS `hostingAccounts` (
        `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
无法向其他服务器发送邮件。
使用or或PEAR的

你能告诉我为什么这不能重定向吗

$sendTo = "https://www.paypal.com/cgi-bin/webscr"
$header[] = "Content-type: text/html";

$dataArray[] = "cmd=".$cmd;
$dataArray[] = "hosted_button_id=".$hosted_button_id;
$dataArray[] = "custom=".$custom;

$post = implode($dataArray, '&');
$post = urlencode($post);


$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTIONTIMEOUT, 30);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

die();

我们不要通过嘲笑来阻止人们提问,提问是我们学习的一种方式。让我们建设性地与他们接触。事实上,OP需要了解您提供链接的问题。出于以下原因,我需要将数据添加到数据库中。1、一旦付款被接受,我使用Paypal API发送和接收参考代码到脚本,然后脚本会查找购买的托管软件包所需的规范,然后使用另一个API创建该托管软件包,激活,然后将相关信息发送给客户。忘了提到它们是定制的托管软件包,不是预先制作的。另外,这是我刚刚完成的。我没有对http头做太多的工作。我知道所有关于-***的事情,只是想找出发帖的方法。你为什么叫die;。。。你不会给脚本时间来完成执行。仍然没有。curl是否确实重定向了用户?
$sendTo = "https://www.paypal.com/cgi-bin/webscr"
$header[] = "Content-type: text/html";

$dataArray[] = "cmd=".$cmd;
$dataArray[] = "hosted_button_id=".$hosted_button_id;
$dataArray[] = "custom=".$custom;

$post = implode($dataArray, '&');
$post = urlencode($post);


$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTIONTIMEOUT, 30);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

die();