What's new

PHP Date picker script

ribbit

Established
di ko na isip pala yung kapag mag rereserve nang date dapat in the future at di na pwede sa past months. bali eto nga problem ko mga paps naka hanap ako nang code na naka disable yung past date sa date picker kaso naka scrip naman baka meron po makapag tulong sa akin paano ilagay sa database ito

eto po code ko
yung line 80 to 90 po yung scrip wala po ako makita sa internet na solution.

PHP:
<?php
session_start();
require('connection.php');

?>
<!DOCTYPE html>
<html>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.7.2.min.js"></script>

<head>

<body bgcolor="lightgray">
    <meta charset="utf-8">
    <title>OBS Reservation</title>
    <link type="text/css" rel="stylesheet" href="ccs/index.css" />
    <link type="text/css" rel="stylesheet" href="ccs/reservation.css" />
    <style>

    </style>
    </head>
    </head>

    <body>

        <?php date_default_timezone_set('Asia/Manila');


        ?>
        <?php
        // If form submitted, insert values into the database.
        if (isset($_REQUEST['Reservation_Date'])) {
            $Date_And_Time_Created = date("y-m-d h:i:s");
            $usern = $_SESSION['usern'];
            $f_name = stripslashes($_REQUEST['f_name']);
            $f_name = mysqli_real_escape_string($con, $f_name);
            $l_name = stripslashes($_REQUEST['l_name']);
            $l_name = mysqli_real_escape_string($con, $l_name);
            $Reservation_Date = stripslashes($_REQUEST['Reservation_Date']);
            $Reservation_Date = mysqli_real_escape_string($con, $Reservation_Date);
            $Service = stripslashes($_REQUEST['Service']);
            $Service = mysqli_real_escape_string($con, $Service);

            $query = "INSERT INTO `reservation_log` (usern,f_name,l_name,Reservation_Date, Service,Date_And_Time_Created)
            VALUES ('$usern','$f_name','$l_name','$Reservation_Date','$Service','$Date_And_Time_Created')";
            $result = mysqli_query($con, $query);
            if ($result) {
                /* echo var_dump($f_name, $l_name) . "<br>"; */
                /* echo var_dump($usern)."<br>"; */
                echo "<div class='form'>
                <h3>You Booked an apointment .</h3>
                <br/>Click here to <a href='index.php'>go back.</a></div>";
            } else {
                echo "test: " . $query;
            }
        } else {
        ?>
            <form action="#" style="border:0px solid #0000">
                <div class="wrap">
                    <nav>
                        <div class="logo"><img src="img/logo.png" height="120" width="120"></div>
                        <ul>
                            <li><a href="index.php">HOME</a></li>
                            <li><a href="reservation.php">BOOK AN APPOINTMENT</a></li>
                            <li><a href="logout.php">Log Out</a></li>

                </div>


                <fieldset>
                    <legend align="center">Appointment Information</legend>
                    <div class="item">
                        <label for="fname"> First Name<span>*</span></label>
                        <input id="fname" type="text" name="f_name" pattern="[^0-9]*" title="Please dont include number or special characters." required />
                    </div>
                    <div class="item">
                        <label for="lname"> Last Name<span>*</span></label>
                        <input id="lname" type="text" name="l_name" pattern="[^0-9]*" title="Please dont include number or special characters." required />
                    </div>
                    <div class="item">
                        <label for="date">Date<span>*</span></label>
                        Date : <input id="date_picker" type="date">
                        <script language="javascript">
                            var today = new Date();
                            var dd = String(today.getDate()).padStart(2, '0');
                            var mm = String(today.getMonth() + 1).padStart(2, '0');
                            var yyyy = today.getFullYear();

                            today = yyyy + '-' + mm + '-' + dd;
                            $('#date_picker').attr('min', today);
                        </script>
                        <i class="fas fa-calendar-alt"></i>
                    </div>
                    <div class="form-group">
                        <select class="form-control" name="Service" id="Service" required>
                            <option disabled selected>Services</option>
                            <option value="Cedula">Cedula</option>
                            <option value="Barangay Clearance">Barangay Clearance</option>
                            <option value="Barangay I.D.">Barangay I.D.</option>
                            <option value="Barangay Permit">Barangay Permit</option>
                            <option value="Barangay Certificate">Barangay Certificate</option>
                            <option value="Barangay Business Permit">Barangay Business Permit</option>
                        </select>
                        <div class="btn-block">
                            <button class="button1" type="submit">Submit</button>
                        </div>
                    </div>

                </fieldset>
            </form>
        <?php } ?>
    </body>

</html>
 
Top