<?php
error_reporting(0);
session_start();
require_once('data_config.php');
if (!empty($_POST["remember"])) {
setcookie("member_login", $_POST["userName"], time() + (10 * 365 * 24 * 60 * 60));
setcookie("member_login", $_POST["password"], time() + (10 * 365 * 24 * 60 * 60));
} else {
if (isset($_COOKIE["member_login"])) {
setcookie("member_login", "");
}
}
include "connect.php";
$selected_game = (!empty($_POST['game'])) ? (string)$_POST['game'] : 'freefire';
$selected_offer = (!empty($_POST['amount'])) ? (int)$_POST['amount'] : 0;
if (isset($_POST['Submit1'])) {
if (empty($_POST['card_no']) || empty($_POST['playerid']) || empty($_POST['confirm_playerid']) || empty($_POST['playername'])) {
$error = "الرجاء ملأ جميع الخانات المطلوبة";
} else {
$card_no = @htmlentities(strip_tags($_POST['card_no']));
$playerid = @htmlentities(strip_tags($_POST['playerid']));
$confirm_playerid = @htmlentities(strip_tags($_POST['confirm_playerid']));
$playername = @htmlentities(strip_tags($_POST['playername']));
if ($playerid != $confirm_playerid) {
$error = "رقم id غير متطابقين";
} else {
$sql = "SELECT * FROM cards WHERE card_no='$card_no' AND finshed=0 LIMIT 1";
$result = mysqli_query($conn, $sql);
$card_exists = (int)mysqli_num_rows($result);
if ($card_exists <= 0) {
$error = 'رقم بطاقة غير صالح او مستخدم من قبل';
} else {
while ($row_card = $result->fetch_assoc()) {
$amount = $row_card['card_amount'];
}
$sql = "SELECT * FROM ordertb WHERE card_no='$card_no' and ordercase in (0,2) LIMIT 1";
$result = mysqli_query($conn, $sql);
$order_exists = (int)mysqli_num_rows($result);
$sql = "SELECT * FROM ordertb_guest WHERE card_no='$card_no' and status in (0,2) LIMIT 1";
$result = mysqli_query($conn, $sql);
$order_exists2 = (int)mysqli_num_rows($result);
if ($order_exists || $order_exists2) {
$error = "رقم البطاقة مستخدم من قبل";
}
}
}
if (empty($error)) {
$created_at = date('Y-m-d H:i:s', time());
$updated_at = date('Y-m-d H:i:s', time());
$sql = "INSERT INTO `ordertb_guest`(`card_no`, `playerid`, `playername`, `created_at`, `update_at`) VALUES ('$card_no','$playerid','$playername','$created_at','$updated_at')";
$insert = mysqli_query($conn, $sql);
if ($insert) {
$orderid = mysqli_insert_id($conn);
$subject = mysqli_real_escape_string($conn, "طلب شحن بقيمة ($amount) بدون تسجيل ");
$comment = mysqli_real_escape_string($conn, "رقم الطلب #$orderid ");
$user = mysqli_real_escape_string($conn, $playername);
$date = date("d-m-Y h:ia");
$query = "
INSERT INTO comments(comment_subject, comment_text,comment_user,comment_time, sorting,user_id,user_type)
VALUES ('$subject', '$comment','$user','$date','1','0','غير مسجل')
";
mysqli_query($conn, $query);
header("location:order_status.php?id={$orderid}&playerid={$playerid}");
exit;
}
}
}
}
$error2 = "";
if (isset($_POST['Submit2'])) {
if (empty((string)$_POST['game']) || empty((string)$_POST['playerid']) || empty((string)$_POST['confirm_playerid']) || empty((string)$_POST['playername']) || empty((int)$_POST['amount']) || !array_key_exists($_POST['game'], $games) || !array_key_exists($_POST['amount'], $offers[$_POST['game']])) {
$error2 = "الرجاء ملأ جميع الخانات المطلوبة";
} else {
if(!empty($_FILES['file']['tmp_name'])){
$file_name = $_FILES['file']['name'];
$file_type = $_FILES['file']['type'];
$tmp_name = $_FILES['file']['tmp_name'];
$file_error = $_FILES['file']['error'];
$file_size = $_FILES['file']['size'];
$file_ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
$fileinfo = @getimagesize($tmp_name);
$width = @$fileinfo[0];
$height = @$fileinfo[1];
}
$game = $_POST['game'];
$playerid = @htmlentities(strip_tags($_POST['playerid']));
$confirm_playerid = @htmlentities(strip_tags($_POST['confirm_playerid']));
$playername = @htmlentities(strip_tags($_POST['playername']));
$amount = $offers[$game][$_POST['amount']];
if(!empty($tmp_name)){
//File verifcation
$allowed_file_extension = array(
"png",
"jpg",
"jpeg",
"pdf"
);
$img_upload_path = 'uploads/' . time() . '-' . rand() . '.' . $file_ext;
if (!in_array($file_ext, $allowed_file_extension)) {
$error2 = "الملفات المدعومة هي (png , jpg , jpeg, pdf فقط";
} elseif ($file_size > 20000000) {
$error2 = "حجم الملف يجب ان لا يتعدى 2 ميغا";
} elseif ($file_ext != "pdf" && empty($fileinfo)) {
$error2 = "الرجاء اختيار صورة صالحة";
} elseif ($playerid != $confirm_playerid) {
$error2 = "رقم id غير متطابقين";
} elseif (empty((int)$playerid)) {
$error2 = "يجب ان يكون رقم id عبارة عن ارقام";
} elseif (!move_uploaded_file($tmp_name, $img_upload_path)) {
$error2 = "لم نتمكن من رفع الصورة , الرجاء مراسلتنا";
}
}else{
$img_upload_path = '#';
if ($playerid != $confirm_playerid) {
$error2 = "رقم id غير متطابقين";
} elseif (empty((int)$playerid)) {
$error2 = "يجب ان يكون رقم id عبارة عن ارقام";
}
}
if (empty($error2)) {
$created_at = date('Y-m-d H:i:s', time());
$updated_at = date('Y-m-d H:i:s', time());
$sql = "INSERT INTO `ordertb_guest`(`card_no`, `amount`, `game`, `playerid`, `playername`, `notes`, `status`, `type`, `file`, `created_at`, `update_at`) VALUES (NULL,'$amount','$game','$playerid','$playername',NULL,'0','baridimob','$img_upload_path','$created_at','$updated_at')";
$insert = mysqli_query($conn, $sql);
if ($insert) {
$orderid = mysqli_insert_id($conn);
$subject = mysqli_real_escape_string($conn, "طلب شحن بقيمة ($amount) بريدي موب ");
$comment = mysqli_real_escape_string($conn, "رقم الطلب #$orderid ");
$user = mysqli_real_escape_string($conn, $playername);
$date = date("d-m-Y h:ia");
$query = "
INSERT INTO comments(comment_subject, comment_text,comment_user,comment_time, sorting,user_id,user_type)
VALUES ('$subject', '$comment','$user','$date','1','0','غير مسجل')
";
mysqli_query($conn, $query);
header("location:order_status.php?id={$orderid}&playerid={$playerid}");
exit;
}
}
}
}
include "inc/header.php";
?>
<div class="choix" style="text-align: center;font-weight: 200;font-size: 18px;"> اختر احد الالعاب للشحن </div>
<hr style="height: 1px;
padding: 0px;
margin: 8px;">
<div class="container itemes">
<div class="row justify-content-center">
<div class="col-6" style="text-align: center">
<button type="button" class="btn btn-outline-primary" style="background: none;color: black;" data-toggle="modal" data-target="#mymodal">
<img class="img" style="display: block; width: 120px; height:160; padding: 29px 10px; margin: 0 auto 13px;border-bottom: 1px solid #ececec;text-align: center;" src="https://cdngarenanow-a.akamaihd.net/gop/app/0000/100/067/icon.png" alt="شحن Free Fire">
<h5 style="margin-top:0px;">FREE FIRE</h5>
</button>
</div>
<!---->
<div class="col-6" style="text-align: center">
<button type="button" class="btn btn-outline-primary" style="background: none; color: black;" data-toggle="modal" data-target="#mymodal">
<img class="img" style="display: block; width: 120px; height:160; padding: 29px 10px;border-bottom: 1px solid #ececec; margin: 0 auto 13px;text-align: center; " src="img/pubgg.png" alt="شحن Free Fire">
<h5 style="margin-top:0px;">PUBG</h5>
</button>
</div>
</div>
<!--row2222-->
<div class="row justify-content-center">
<div class="col-6" style="text-align: center; margin-bottom: 5px;">
<button type="button" class="btn btn-outline-primary" style="background: none; color: black;" data-toggle="modal" data-target="#mymodal">
<img class="img" style="display: block; width: 120px; height:160; padding: 29px 10px; margin: 0 auto 13px;border-bottom: 1px solid #ececec;text-align: center;" src="img/ccp.png" alt="شحن Free Fire">
<h5 style="margin-top:0px;">BARIDI MOB</h5>
</button>
</div>
<div class="col-6" style="text-align: center; margin-bottom: 5px;">
<button type="button" class="btn btn-outline-primary " style="background: none; color: black;" data-toggle="modal" data-target="#mymodal">
<img class="img" style="display: block; width: 120px; height:160; padding: 29px 10px;border-bottom: 1px solid #ececec; margin: 0 auto 13px;text-align: center;" src="img/ORDER.png" alt="شحن Free Fire">
<h5 style="margin-top:0px;">MY ORDER</h5>
</button>
</div>
</div>
<!--row2222-->
<!--mooooooooodle-->
<div id="mymodal" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" style="margin-top: -10px;color: red;" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">اضافة بطاقة جديدة</h4>
</div>
<form action="" method="post" class="new-card-form">
<?php if (isset($error) && !empty($error)) { ?>
<div class="alert alert-danger">
<strong>خطأ!</strong> <?= $error ?>
</div>
<?php } ?>
<div class="form-group">
<div class="col-md-12">
<label for="playerid" style="font-weight: bold;color: #3e5a94;">رقم id<span class="required" style="color:red">*</span></label>
<input style="border: 1px solid #39b6b9" type="text" required name="playerid" class="form-control input-md" placeholder="أدخل رقم id" value="<?= @$_POST['playerid'] ?>">
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<label for="confirm_playerid" style="font-weight: bold;color: #3e5a94;">أعد رقم id<span class="required" style="color:red">*</span></label>
<input style="border: 1px solid #39b6b9" type="text" required name="confirm_playerid" class="form-control input-md" placeholder="أعد ادخال رقم id" value="<?= @$_POST['confirm_playerid'] ?>">
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<label for="playername" style="font-weight: bold;color: #3e5a94;">(للتأكيد) اسمك داخل اللعبة<span class="required" style="color:red">*</span></label>
<input style="border: 1px solid #39b6b9" type="text" required name="playername" class="form-control input-md" placeholder="أدخل اسمك داخل اللعبة" value="<?= @$_POST['playername'] ?>">
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<label for="card_no" style="font-weight: bold;color: #3e5a94;">رقم البطاقة<span class="required" style="color:red">*</span></label>
<input type="text" required name="card_no" class="form-control input-md" style="border: 1px solid #39b6b9"placeholder="أدخل رقم البطاقة" value="<?= @$_POST['card_no'] ?>">
</div>
</div>
<div class="row mt-lg">
<div class="col-md-12 center">
<input type="submit" name="Submit1" style="margin-left: 15px;" value="ارسال الطلب" class="btn btn-success pull-left mb-xl">
<a href="order_status.php" class="btn btn-primary pull-left mb-xl mx-2">تتبع طلبي</a>
</div>
</div>
</form>
</div>
</div>
<!--mooooooooodle-->
</div>
<script>
var myForm = document.querySelector('#myform');
myForm.addEventListener('submit' ,function(e){
e.preventDefault(); // منع تحديث الصفحة
sendAjaxRequest();
});
$(function() {
$(document).on('input change', '#game', function() {
var offers;
console.log($(this).val())
if ($(this).val() == "pubg") {
offers = ` <?php
foreach ($offers['pubg'] as $key => $offer) {
$price = ($key != 0) ? ' (' . $prices_da_baridimob['pubg'][$offer] . ' DA)' : '';
$price_paysera = ($key != 0) ? ' - (' . $prices_paysera['pubg'][$offer] . ' EUR)' : '';
?>
<option value="<?= $key ?>" style="font-weight: bold;font-size: 18px"><?= $offer . $price .$price_paysera?></option>
<?php
}
?>`;
} else {
offers = `<?php
foreach ($offers['freefire'] as $key => $offer) {
$price = ($key != 0) ? ' (' . $prices_da_baridimob['freefire'][$offer] . ' DA)' : '';
$price_paysera = ($key != 0) ? ' - (' . $prices_paysera['freefire'][$offer] . ' EUR)' : '';
?>
<option value="<?= $key ?>" style="font-weight: bold;font-size: 18px"><?= $offer . $price .$price_paysera ?></option>
<?php
}
?>`;
}
$('#amount_offers').html(offers);
})
})
</script>
<?php include "inc/footer.php"; ?>
<?php
error_reporting(0);
if (isset($_POST["login"])) {
$userName = htmlspecialchars($_POST['userName']);
$password = htmlspecialchars($_POST['password']);
$countc = 0;
$resc = mysqli_query($conn, "select * from users where BINARY userName='$userName' && BINARY password= '$password' && active = '0' LIMIT 1");
$countc = mysqli_num_rows($resc);
if ($countc > 0) {
?>
<script type="text/javascript">
document.getElementById("erroractive").style.display = "block";
</script>
<?php
} else {
$counts = 0;
$ress = mysqli_query($conn, "select * from users where BINARY userName='$userName' && BINARY password= '$password' && active = '2' LIMIT 1");
$counts = mysqli_num_rows($ress);
if ($counts > 0) {
?>
<script type="text/javascript">
document.getElementById("errorstop").style.display = "block";
</script>
<?php
} else {
$count = 0;
$res = mysqli_query($conn, "select * from users where BINARY userName='$userName' && BINARY password= '$password' && active = '1' LIMIT 1");
$count = mysqli_num_rows($res);
if ($count == 0) {
?>
<script type="text/javascript">
document.getElementById("error").style.display = "block";
</script>
<?php
} else {
$sql = "select * from users where BINARY userName='$userName' && BINARY password= '$password' && active = '1' ";
$result = $conn->query($sql);
while ($row = $result->fetch_assoc()) {
$logintype = $row['logintype'];
if ($logintype == 1) {
?>
<script type="text/javascript">
document.getElementById("success").style.display = "block";
</script>
<?php
$_SESSION["userName"] = $userName;
?>
<script type="text/javascript">
window.location = "Supermarket";
</script>
<?php
} elseif ($logintype == 2) {
?>
<script type="text/javascript">
document.getElementById("success").style.display = "block";
</script>
<?php
$_SESSION["userName"] = $userName;
?>
<script type="text/javascript">
window.location = "client";
</script>
<?php
}
}
}
}
}
}
?>
لقد وضعت المودل كما شرحت لي انه يعمل في حالة الفورم صحيح فانه يرسل الطلب الى قواعد البيانات
لاكن في حالة الخطا تظهر رسالة الخطأ داخل المودل وتختفي معه يعني حتى اضعط على الصورة من جديد
كيف اجعل رسالة الخطأ تظهر خارج المودل بعد ارسال الطلب وليس داخله كي تظهر للمستخدم انه مخطأ
هدي هي رسالة الخطأ المحتواة داخل المودل
<?php if (isset($error) && !empty($error)) { ?>
<div class="alert alert-danger">
<strong>خطأ!</strong> <?= $error ?>
</div>
<?php } ?>