html - PHP SQL : How to allow access to my website page for only a certain time in a day? -
html - PHP SQL : How to allow access to my website page for only a certain time in a day? -
i have html/php page, illustration mypage.php illustration contains
<?php echo "hello everyone"; echo "please fill below form"; ?> <form action="form.php" method="post"> first name:<br> <input type="text" id="fname" name="fname"> <br> lastly name:<br> <input type="text" id="lname" name="lname"> <br><br> <input type="submit" value="submit"> </form> <?php echo "sorry it's time on today. time is" . date("h:i:sa"). echo "please come 1 time again tomorrow @ 11:00 am"; ?>
what should code within php page, can accessible 11:00 2:00 pm ist. if time between 11am 2pm should show html form, if time has passed should print sec message, sorry it's time on today....
the saving info database form.php
<?php $servername = "localhost"; $username = "database1"; $password = "xxxxxxxx"; $dbname = "database1"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } //escape variables security $fname = mysqli_real_escape_string($conn, $_post['fname']); $lname = mysqli_real_escape_string($conn, $_post['lname']); $sql = "insert mytable (fname,lname) values ('$fname','$lname')"; if ($conn->query($sql) === true) { echo "successfully saved"; } else { echo "error: go , seek 1 time again ! " . $sql . "<br>" . $conn->error; } $conn->close(); ?>
what should code within saving form.php, check time. if time between 11 2 pm should save form. if time has passed should say, sorry info cannot saved time limit has reached.
php html mysql time
Comments
Post a Comment