test - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of test.php
- <?php
- function serial_query(){
- require("connect.php");
- $query = "SELECT MAX(ser) ser FROM `customers`;";
- $result = $conn -> query($query);
- while ($row = $result -> fetch_assoc()) {
- $ser = $row["ser"] +1 ;
- }
- $ser;
- return $ser;
- }
- function time_period($P,$d,$ser){
- require("connect.php");
- $date = new DateTime("$d");
- switch ($P) {
- case "1": // Freeze
- $sql = "select * from `customers` where `ser` = $ser ";
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0) {
- while ($row = mysqli_fetch_assoc($result)) {
- $subperiod = $row["subscrip_period"];
- }
- switch($subperiod){
- case "3": // one month
- $ex_date = 5;
- date_add($date, date_interval_create_from_date_string("$ex_date days"));
- break;
- case "4": // 3 Months
- $ex_date = 14;
- date_add($date, date_interval_create_from_date_string("$ex_date days"));
- break;
- case "5": // 6 Months
- $ex_date = 1;
- date_add($date, date_interval_create_from_date_string("$ex_date months"));
- break;
- case "6": // One Year
- $ex_date = 2;
- date_add($date, date_interval_create_from_date_string("$ex_date months"));
- break;
- }
- }
- $expire = date_format($date, "Y-m-d");
- break;
- case "2": // 12 days
- $ex_date = 1;
- date_add($date, date_interval_create_from_date_string("$ex_date months"));
- $expire = date_format($date, "Y-m-d");
- break;
- case "3": // one month
- $ex_date = 1;
- date_add($date, date_interval_create_from_date_string("$ex_date months"));
- $expire = date_format($date, "Y-m-d");
- break;
- case "4": // 3 months
- $ex_date = 3;
- date_add($date, date_interval_create_from_date_string("$ex_date months"));
- $expire = date_format($date, "Y-m-d");
- break;
- case "5": // 6 months
- $ex_date = 6;
- date_add($date, date_interval_create_from_date_string("$ex_date months"));
- $expire = date_format($date, "Y-m-d");
- break;
- case "6": // one year
- $ex_date = 1;
- date_add($date, date_interval_create_from_date_string("$ex_date years"));
- $expire = date_format($date, "Y-m-d");
- break;
- case "8": // 8 session
- $ex_date = 1;
- date_add($date, date_interval_create_from_date_string("$ex_date months"));
- $expire = date_format($date, "Y-m-d");
- break;
- default:
- $ex_date = 0;
- }
- return $expire ;
- }
- function _chk(){
- $_date=new DateTime('now');
- if ($_date->format('y') == '24' && $_date->format('m') <= '04' ) {
- return 0;
- } else{ return 1;}
- }
- function get_header(){
- $header = '
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <meta name="description" content="">
- <meta name="author" content="">
- <link href="https://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i&display=swap" rel="stylesheet">
- <title>FLEET CLUB - GYM</title>
- <!-- Additional CSS Files -->
- <link rel="shortcut icon" href="assets/images/mahrosa.png">
- <link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
- <link rel="stylesheet" type="text/css" href="assets/css/font-awesome.css">
- <link rel="stylesheet" href="assets/css/templatemo-training-studio.css">
- <!-- UIkit CSS -->
- <link rel="stylesheet" href="assets/css/uikit.min.css" />
- <script>
- </>
- </head>
- <body>
- <!-- ***** Preloader Start ***** -->
- <div id="js-preloader" class="js-preloader">
- <div class="preloader-inner">
- <span class="dot"></span>
- <div class="dots">
- <span></span>
- <span></span>
- <span></span>
- </div>
- </div>
- </div>
- <!-- ***** Preloader End ***** -->
- <!-- ***** Header Area Start ***** -->
- <header class="header-area header-sticky">
- <div class="container">
- <div class="row">
- <!-- <div class="col-1">
- <img style="width: 60px;height: 50px;position: relative;top:10px;left:1px" src="assets/images/mahrosa.png">
- </div> -->
- <div class="col-12">
- <nav class="main-nav">
- <!-- ***** Logo Start ***** -->
- <a href="index.php" class="logo">FLEET CLUB<em> GYM</em></a>
- <!-- ***** Logo End ***** -->
- <!-- ***** Menu Start ***** -->
- <ul class="nav">
- <li class="scroll-to-section"><a href="index.php" class="active">Home</a></li>
- </ul>
- <a class="menu-trigger">
- <span>Menu</span>
- </a>
- <!-- ***** Menu End ***** -->
- </nav>
- </div>
- </div>
- </div>
- </header>
- <!-- ***** Header Area End ***** -->
- ';
- return $header;
- }
- function get_footer(){
- $footer = '
- <!-- ***** Footer Start ***** -->
- <footer>
- <div class="container">
- <div class="row">
- <div class="col-lg-12">
- <p>Copyright © 2023 Fleet Club <em style="color:var(--orange);font-size:15px;">Mahrousa</em> - IT Team
- - Designed by - Tarek Youssef </p>
- </div>
- </div>
- </div>
- </footer>
- <!-- jQuery -->
- <script src="assets/js/jquery-2.1.0.min.js"></script>
- <script src="assets/js/3.7.1jquery.min.js"></script>
- <!-- Bootstrap -->
- <script src="assets/js/popper.js"></script>
- <script src="assets/js/bootstrap.min.js"></script>
- <!-- UIkit JS -->
- <script src="assets/js/uikit.min.js"></script>
- <script src="assets/js/uikit-icons.min.js"></script>
- <!-- Plugins -->
- <script src="assets/js/scrollreveal.min.js"></script>
- <script src="assets/js/waypoints.min.js"></script>
- <script src="assets/js/jquery.counterup.min.js"></script>
- <script src="assets/js/imgfix.min.js"></script>
- <script src="assets/js/mixitup.js"></script>
- <script src="assets/js/accordions.js"></script>
- <!-- Global Init -->
- <script src="assets/js/custom.js"></script>
- <script>
- (() => {
- "use strict"
- // Fetch all the forms we want to apply custom Bootstrap validation styles to
- const forms = document.querySelectorAll(".needs-validation")
- // Loop over them and prevent submission
- Array.from(forms).forEach(form => {
- form.addEventListener("submit", event => {
- if (!form.checkValidity()) {
- event.preventDefault()
- event.stopPropagation()
- }
- form.classList.add("was-validated")
- }, false)
- })
- })();
- document.getElementById("main_form").addEventListener("submit", function(event) {
- var gen = document.forms["main_form"]["gender"];
- var subtype = document.forms["main_form"]["subtype"];
- if (gen[0].checked === false && gen[1].checked === false) {
- event.preventDefault(); // Prevent form submission
- alert("برجاء تحديد النوع"); // Display an error message
- } else if (subtype[0].checked === false && subtype[1].checked === false && subtype[2].checked === false) {
- event.preventDefault(); // Prevent form submission
- alert("برجاء تحديد نوع الاشتراك"); // Display an error message
- }
- });
- // search:
- $(document).ready(function() {
- $("#live_search").keyup(function() {
- var input = $(this).val();
- if (input != "") {
- $.ajax({
- url: "livesearch.php",
- method: "POST",
- data: {
- input: input
- },
- success: function(data) {
- $("#searchResult").html(data);
- }
- })
- } else {
- $("#searchResult").css("Display", "none");
- }
- });
- });
- </script>
- </body>
- </html>';
- return $footer;
- }
- function get_data($df,$dt){
- require ("connect.php");
- $arr=["12 حصة","شهري","3 شهور","6شهور","سنوي"];
- $condition_date ="`subscrip_date` BETWEEN '$df 00:00:01' AND '$dt 23:59:59'";
- echo '<table style="text-align:center;" class="table table-dark table-hover table-bordered"><tr>
- <th rowspan="2">نوع الاشتراك</th>
- <th colspan="2">قوات مسلحة</th>
- <th colspan="2">محروسة</th>
- <th colspan="2">مدني</th>
- <!--<th rowspan="2" >الإجمالي </th>-->
- </tr>
- <tr>
- <th>رجال</th>
- <th>سيدات </th>
- <th>رجال</th>
- <th>سيدات </th>
- <th>رجال</th>
- <th>سيدات </th>
- </tr>';
- for ($sub_period=2; $sub_period<=6 ; $sub_period++) {
- echo "<tr> <th>".$arr[$sub_period-2]."</th>";
- for ($sub_type= 1; $sub_type<=3; $sub_type++) {
- for ($g= 1; $g<=2; $g++) {
- $sql = "SELECT COUNT(*) FROM `customers` WHERE `gender` = $g AND `subscrip_period` = $sub_period AND `subtype` = $sub_type AND".$condition_date;
- $result = mysqli_query($conn, $sql);
- while ($row = mysqli_fetch_assoc($result)) {
- $ss = $row["COUNT(*)"];
- echo "<th>" . $ss . "</th>";
- }
- }
- }
- // $tot = "SELECT COUNT(*) FROM `customers`Where `subscrip_period` = $sub_period AND" . $condition_date;
- // $result = mysqli_query($conn, $tot);
- // while ($row = mysqli_fetch_assoc($result)) {
- // $ss = $row["COUNT(*)"];
- // echo "<th>" . $ss . "</th>";
- // }
- }
- //Total Row:
- echo "<tr>
- <th>الاجمالي</th>";
- for ($sub_type= 1; $sub_type<=3; $sub_type++) {
- for ($g= 1; $g<=2; $g++) {
- $sql = "SELECT COUNT(*) FROM `customers` WHERE `gender` = $g AND `subtype` = $sub_type AND ".$condition_date;
- $result = mysqli_query($conn, $sql);
- while ($row = mysqli_fetch_assoc($result)) {
- $ss = $row["COUNT(*)"];
- echo "<th>" . $ss . "</th>";
- }
- }
- }
- //Last Row
- $sql = "SELECT COUNT(*) FROM `customers` WHERE ".$condition_date;
- $result = mysqli_query($conn, $sql);
- while ($row = mysqli_fetch_assoc($result)) {
- $ss = $row["COUNT(*)"];
- echo ' <tr>
- <th colspan="4">إجمالي الأعضاء المشتركين</th>
- <th colspan="4">'.$ss.'</th>
- </tr>';
- }
- echo"</tr></table>";
- }
- function get_data2($f,$t){
- require ("connect.php");
- $fdate = date_create($f);
- date_modify($fdate, '-1 month');
- $newfDate = date_format($fdate, 'Y-m-d');
- $tdate = date_create($t);
- date_modify($tdate, '-1 month');
- $newtDate = date_format($tdate, 'Y-m-d');
- //echo"<h4 style='color:white'>$newfDate -->$newtDate</h4> ";
- echo
- '
- <table style="text-align:center;" class="table table-dark table-hover table-bordered">
- <tr>
- <th rowspan="2">نوع الاشتراك</th>
- <th colspan="2">قوات مسلحة</th>
- <th colspan="2">محروسة</th>
- <th colspan="2">مدني</th>
- </tr>
- <tr>
- <th>رجال</th>
- <th>سيدات </th>
- <th>رجال</th>
- <th>سيدات </th>
- <th>رجال</th>
- <th>سيدات </th>
- </tr>
- <tr>
- <th></th>
- ';
- for ($sub_type= 1; $sub_type<=3; $sub_type++) {
- for ($g= 1; $g<=2; $g++) {
- $sql = "SELECT COUNT(*) FROM `customers` WHERE `gender` = $g AND `subtype` = $sub_type AND `subscrip_ex` BETWEEN '$newfDate' AND '$newtDate'";
- $result = mysqli_query($conn, $sql);
- while ($row = mysqli_fetch_assoc($result)) {
- $ss = $row["COUNT(*)"];
- echo "<th>" . $ss . "</th>";
- }
- }
- }
- echo "</table>";
- }
- function upload_imgs($ser,$filename)
- {
- //=====================[ Upload Image ]==============================
- try {
- // Create the 'profiles/newfolder' directory if it doesn't exist
- if (!is_dir('profiles/newfolder')) {
- mkdir('profiles/newfolder', 0777, true);
- // Rename the 'profiles/newfolder' directory to 'profiles/$ser'
- rename('profiles/newfolder', 'profiles/' . $ser);
- }
- } catch (Exception $e) {
- // If an error occurs, display the error message
- echo "Error: couldn't create file !" . $e->getMessage();
- }
- $target_dir = "profiles/$ser";
- $target_file = $target_dir . basename($_FILES[$filename]["name"]);
- $uploadOk = 1;
- $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
- // Check if image file is a actual image or fake image
- if (isset($_POST["submit"])) {
- $check = getimagesize($_FILES[$filename]["tmp_name"]);
- if ($check !== false) {
- echo "File is an image - " . $check["mime"] . ".";
- $uploadOk = 1;
- } else {
- echo "File is not an image.";
- $uploadOk = 0;
- }
- }
- // Rename file
- $Extantion = pathinfo($target_file, PATHINFO_EXTENSION);
- $randam = rand(0,99);
- $rename = $ser."-".$randam;
- $newfilename = $rename.".".$Extantion;
- // Check if file already exists
- if (file_exists($newfilename)) {
- // echo "Sorry, file already exists.";
- $uploadOk = 0;
- }
- // Check file size
- if ($_FILES[$filename]["size"] > 5000000) { //5MB
- // echo "Sorry, your file is too large.";
- $uploadOk = 0;
- }
- // Allow certain file formats
- if (
- $imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
- && $imageFileType != "gif" && $imageFileType != "jfif"
- ) {
- // echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
- $uploadOk = 0;
- }
- // Check if $uploadOk is set to 0 by an error
- if ($uploadOk == 0) {
- // echo "Sorry, your file was not uploaded.";
- // if everything is ok, try to upload file
- } else {
- if (move_uploaded_file($_FILES[$filename]["tmp_name"],$target_dir.'/'.$newfilename)) {
- $FILE_NAME = $target_dir.'/'.$newfilename;
- require("connect.php");
- $update = "UPDATE `customers` SET `profile_img` ='$FILE_NAME' WHERE `ser` = '$ser'";
- $conn->query($update);
- //echo "The file " . htmlspecialchars(basename($_FILES[$filename]["name"])) . " has been uploaded.";
- } else {
- echo "Sorry, there was an error uploading your file.";
- }
- }
- }
- //Barcode Generator
- function generateBarcode($text) {
- require_once('vendor/autoload.php'); // Path to autoload.php file of TCPDF library
- $barcodeobj = new TCPDFBarcode($text, 'C39');
- $barcode = $barcodeobj->getBarcodeSVGcode(1, 30, '#04047f');
- $barcode = strtolower($barcode); // Convert the SVG code to lowercase
- return $barcode;
- }
- ?>
File Description
- test
- PHP Code
- 28 Mar-2024
- 16.44 Kb
You can Share it:
Latest PHP Pastes