0% found this document useful (0 votes)
8 views3 pages

Pay

The document is a PHP script that connects to a MySQL database to retrieve booking details based on a provided booking ID. If the booking exists, it generates a PayPal payment form with the booking information and automatically submits it. If no booking ID is provided or the booking is not found, it displays an error message.

Uploaded by

qadry4688
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Pay

The document is a PHP script that connects to a MySQL database to retrieve booking details based on a provided booking ID. If the booking exists, it generates a PayPal payment form with the booking information and automatically submits it. If no booking ID is provided or the booking is not found, it displays an error message.

Uploaded by

qadry4688
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

<?

php

include 'config.php';

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "husky_project";

// ‫االتصال بقاعدة البيانات‬

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

// ‫` التحقق من أن‬booking_id` ‫تم تمريره‬

if (isset($_GET['booking_id'])) {

$booking_id = $_GET['booking_id'];

// ‫الحصول على تفاصيل الحجز من قاعدة البيانات‬

$sql = "SELECT * FROM bookings WHERE id = $booking_id";

$result = $conn->query($sql);

if ($result && $result->num_rows > 0) {

$booking = $result->fetch_assoc();
$hotel_id = $booking['hotel_id'];

$user_name = $booking['user_name'];

$user_email = $booking['user_email'];

// ‫ قم بتهيئة عملية الدفع باستخدام‬PayPal API ‫هنا‬

// ‫ التعليمات التالية هي مثال لتوجيه المستخدم إلى‬PayPal

$paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";

$business_email = "[email protected]";

$return_url = "http://localhost/web/success.php";

$cancel_url = "http://localhost/web/cancel.php";

$notify_url = "http://localhost/web/ipn.php";

$item_name = "Booking for Hotel ID: " . $hotel_id;

$item_amount = 100; // ‫يمكنك تخصيص المبلغ هنا‬

echo '<form action="' . $paypal_url . '" method="post" name="frmPayPal1">

<input type="hidden" name="business" value="' . $business_email . '">

<input type="hidden" name="cmd" value="_xclick">

<input type="hidden" name="item_name" value="' . $item_name . '">

<input type="hidden" name="amount" value="' . $item_amount . '">

<input type="hidden" name="currency_code" value="USD">

<input type="hidden" name="return" value="' . $return_url . '">

<input type="hidden" name="cancel_return" value="' . $cancel_url . '">

<input type="hidden" name="notify_url" value="' . $notify_url . '">

<input type="hidden" name="custom" value="' . $booking_id . '">


<input type="submit" value="Pay Now">

</form>';

echo '<script type="text/javascript">

document.frmPayPal1.submit();

</script>';

} else {

echo "Error: No booking found with ID = $booking_id. SQL Error: " . $conn->error;

} else {

echo "Error: No booking ID provided.";

$conn->close();

?>

You might also like