Ciao ragazzi! Sto provando Sandbox Paypal su un sito prova di altervista. Ho modificato leggermente questo script fornito da paypal stesso:

Codice PHP:
<?PHP



// leggi il post del sistema PayPal e aggiungi cmd

$req 'cmd=_notify-validate';



foreach (
$_POST as $key => $value

{

    
$value urlencode(stripslashes($value));

    
$req .= "&$key=$value";

}



// reinvia al sistema PayPal per la convalida

    
$header "POST /cgi-bin/webscr HTTP/1.0\r\n";

    
$header .= "Host: [url]http://www.sandbox.paypal.com:80\r\n[/url]";

    
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";

    
$header .= "Content-Length: ".strlen($req)."\r\n\r\n";

    
$fp fsockopen("http://www.sandbox.paypal.com"80$errno$errstr30);    //se il socket non viene aperto, avrò degli errori $errno,$errstr

        

        





// assegna variabili inviate a variabili locali

$item_name $_POST['item_name'];

$item_number $_POST['item_number'];

$payment_status $_POST['payment_status'];

$payment_amount $_POST['mc_gross'];

$payment_currency $_POST['mc_currency'];

$txn_id $_POST['txn_id'];

$receiver_email $_POST['receiver_email'];

$payer_email $_POST['payer_email'];



if (!
$fp

{

    
$stringa "ERRORE. NON FUNZIONA";

        
$fileout "save.txt";

        
$out fopen($fileout,"a") or die("Impossibile aprire il file!!");

        
fwrite($out,$stringa."\n") or die("Impossibile scrivere sul file!!");

        
fclose($out) or die("Impossibile chiudere il file!!");

    
header("Location: errore.html");



else 

{

    
fputs ($fp$header $req);

    while (!
feof($fp)) 

    {

        
$res fgets ($fp1024);

        

        if (
strcmp ($res"VERIFIED") == 0

        {

            
// controlla che payment_status sia Completed

            // controlla che txn_id non sia stato già elaborato

            // controlla che receiver_email sia il tuo indirizzo email PayPal principale

            // controlla che payment_amount/payment_currency siano corretti

            // elabora pagamento

        

        

        

        
$stringa "PAGAMENTO RICEVUTO";

        
$fileout "save.txt";

        
$out fopen($fileout,"a") or die("Impossibile aprire il file!!");

        
fwrite($out,$stringa."\n") or die("Impossibile scrivere sul file!!");

        
fclose($out) or die("Impossibile chiudere il file!!");

        

        
header("Location: ricevuto.html");

        }

        else if (
strcmp ($res"INVALID") == 0

        {

            
// registra indagine manuale

            
$stringa "INVALIDO";

            
$fileout "save.txt";

            
$out fopen($fileout,"a") or die("Impossibile aprire il file!!");

            
fwrite($out,$stringa."\n") or die("Impossibile scrivere sul file!!");

            
fclose($out) or die("Impossibile chiudere il file!!");

        }

    }

    

    
fclose ($fp);

}

?>
impostando la porta 80 invece della 443, ma non capisco dove caspita sbaglio...non mi fa ne il reindirizzamento ne il salvataggio su file txt