0

「今すぐ支払う」ペイパル ボタンを作成しました。ユーザーはそれをクリックしてアーティストを予約できます。記入しなければならない詳細 (アーティスト名、イベントの日付、イベントの場所など) がたくさんあり、最後のオプションは支払いです。

以下は通常のペイパルフォームです。また、データベースからいくつかの変数を使用します (アーティストの名前と姓、予算、ID など)

index.php

$url='https://www.sandbox.paypal.com/cgi-bin/webscr'; ?>
$email='my-email@gmail.com';
<form enctype="multipart/form-data" action='<?php echo $url; ?>' method='post'>
<input type='hidden' name='business' value='<?php echo $email; ?>'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='item_name' value='<?php echo $name . " " . $surname;?>'>
<input type='hidden' name='item_number' value='<?php echo $artist_id;?>'>
<input type='hidden' name='amount' value='<?php echo $price;?>'>
<input type='hidden' name='buyer_name' value='<?php echo $b_name; ?>'>
<input type='hidden' name='buyer_phone' value='<?php echo $phone; ?>'>

<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='currency_code' value='EUR'>
<input type='hidden' name='handling' value='0'>
<input type='hidden' name='cancel_return' value='http://mywebsite.com/fail.php'>
<input type='hidden' name='return' value='http://mywebsite.com/success.php'>

<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">

ユーザーがボタンをクリックすると、製品の詳細などが表示されるペイパル サイトに移動します。支払いが成功すると、データ (cmd、item_name、item_number、amount など) を取得するための success.php スクリプトにユーザーが送信されます。 ) index.php のフォームから

成功.php

<?php
    $artist_id = $_POST['item_number'];
    $buyer_name = $_POST['buyer_name'];
    $buyer_phone = $_POST['buyer_phone'];
    $item_transaction = $_POST['tx'];
    $item_price = $_POST['amt'];

    echo "Name: $item_no , Surname: $buyer_name, Price: $buyer_phone, ID: $item_transaction  $item_price<br/>";

    //retrieve artist's details
    $getArtist = mysql_query("SELECT * FROM artist WHERE artist_id = '$item_no'");
    $details = mysql_fetch_array($getArtist);
    $name = $details['artist_name']; $surname = $details['artist_surname']; $price = $details['artist_budget']; $artist_id = $details['artist_id'];

    //$result = mysql_query("INSERT INTO booked_event (pid, buyer_name, buyer_phone, saledate, transactionid) VALUES('$singer_no', '$buyer_name', '$buyer_phone','$event_date','$item_transaction')");
    //if($result){
    //    echo "<p style='text-align: center;'><img src='images/success.png'><br/><br/>";
    //    echo "We will contact you as soon as possible for further details! Please check your email<br/>";
    //    echo "<a href='book.php'><b>Go Back</b></a></p><br/>";

    //}else{
    //    echo "Payment Error";
    //}
        echo "Name: $name , Surname: $surname, Price: $price, ID: $artist_id";
    }
    else
    {
    echo "Payment Failed";
    }
?>

問題は、誰かがアーティストを予約したときにデータベースに保存するための詳細を取得できないことです。詳細をエコーし​​ようとしましたが、何も出力されません (echo "Name: $item_no , Surname: $buyer_name, Price: $buyer_phone, ID: $item_transaction $item_price を参照)。

理由を知っている人はいますか?私は何か間違ったことをしていますか?

4

1 に答える 1