File manager - Edit - /home/gppowercontrol/public_html/razorpay/result.php
Back
<?php session_start(); include('../include/connection.php'); // Show PHP errors for debugging (Remove this in production) ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); if (isset($_GET['order_id']) && isset($_GET['payment_id']) && $_GET['payment_id'] != '' && $_GET['order_id'] != '') { $payment_id = $_GET['payment_id']; $order_id = $_GET['order_id']; if (isset($_SESSION['cart'])) { unset($_SESSION['cart']); } // Update order in database $update_sql = "UPDATE `orders` SET `payment_status` = '1', `transaction_id` = '$payment_id' WHERE `order_id` = '$order_id'"; $update_res = mysqli_query($con, $update_sql); if ($update_res) { // Fetch order details $order_sql = "SELECT * FROM `orders` WHERE `order_id` = '$order_id'"; $order_res = mysqli_query($con, $order_sql); if ($order_res && mysqli_num_rows($order_res) > 0) { $order = mysqli_fetch_assoc($order_res); $name = $order['fname'] . " " . $order['lname']; $email = $order['email']; $phone = $order['phone']; $price = $order['final_price']; $address = $order['address1'] . " " . $order['address2']; $pincode = $order['pincode']; $notes = $order['notes']; $discount = $order['discount']; $shipping_charge = $order['shipping_charge']; // $tax = $order['tax']; $delivery = empty($order['delivery']) ? 'Free Delivery' : $order['delivery']; $product_name = json_decode($order['product_name']); $product_quantity = json_decode($order['product_quantity']); $product_price = json_decode($order['product_price']); // Build email content $message = "<h2>New Order Received</h2>"; $message .= "<p><b>Invoice ID:</b> " . $order['id'] . "</p>"; $message .= "<p><b>Order ID:</b> $order_id</p>"; $message .= "<p><b>Transaction ID:</b> $payment_id</p>"; $message .= "<p><b>Name:</b> $name</p>"; $message .= "<p><b>Email:</b> $email</p>"; $message .= "<p><b>Phone:</b> $phone</p>"; $message .= "<p><b>Address:</b> $address, $pincode</p>"; $message .= "<p><b>Notes:</b> $notes</p>"; $message .= "<h3>Products:</h3><ul>"; foreach ($product_name as $key => $pname) { $quantity = $product_quantity[$key]; $price_single = $product_price[$key]; $message .= "<li>$pname - Qty: $quantity - Price: Rs.$price_single</li>"; } $message .= "</ul>"; if (!empty($discount) && $discount != '0') { $message .= "<p><b>Discount:</b> Rs.$discount</p>"; } if (!empty($shipping_charge) && $shipping_charge != '0') { $message .= "<p><b>Shipping Charge:</b> Rs.$shipping_charge</p>"; }else{ $message .= "<p><b>Shipping Charge:</b> Free</p>"; } // if (!empty($tax) && $tax != '0') { // $message .= "<p><b>Tax:</b> Rs.$tax</p>"; // } // $message .= "<p><b>Delivery Charges:</b> Rs.$delivery</p>"; $message .= "<p><b>Total Amount:</b> Rs.$price</p>"; // Send Email to Admin $admin_email = "gppowercontrol@gmail.com"; $admin_subject = "New Order Placed - Order ID $order_id"; $admin_headers = "MIME-Version: 1.0\r\n"; $admin_headers .= "Content-Type: text/html; charset=UTF-8\r\n"; $admin_headers .= "From: gppowercontrol@gmail.com\r\n"; mail($admin_email, $admin_subject, $message, $admin_headers); // Send Email to Customer $customer_subject = "Thank you for your order!"; $customer_headers = "MIME-Version: 1.0\r\n"; $customer_headers .= "Content-Type: text/html; charset=UTF-8\r\n"; $customer_headers .= "From: gppowercontrol@gmail.com\r\n"; $customer_message = "<h2>Thank you, $name!</h2><p>We have received your order.</p>" . $message; mail($email, $customer_subject, $customer_message, $customer_headers); // Redirect to Thank You page header("Location: https://gppowercontrol.com/thank-you.php?id=$order_id"); exit(); } else { echo "<script>alert('Order not found.');</script>"; } } else { echo "<script>alert('Failed to update order.');</script>"; } } else { echo "<script>alert('Invalid request.');</script>"; } ?>
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 1.17 |
proxy
|
phpinfo
|
Settings