JezK
Edit File: myform.php
<?php include('db_connect_db_new.php'); session_start(); error_reporting(E_ALL); ini_set("display_errors",1); if($_SESSION["loggedIn"] == 0) header("location: index.php"); $user_ = $_SESSION["user"]; ?> <html> <head> <!-- <meta http-equiv = "refresh" content = "10;url= front.php"/> --> <link rel = "stylesheet" href= "BootStrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="navbar3.css"> <link rel="stylesheet" type="text/css" href="myform.css"> <script src= "BootStrap/js/bootstrap.min.js"></script> <script src="BootStrap/js/jQuery.min.js"></script> <script src="BootStrap/js/bootstrap.min.js"></script> <script type="text/javascript" src="webcam/webmaster/webcam.js"></script> <style> html { position: relative; min-height: 100%; }body { /* Margin bottom by footer height */ margin-bottom: 40px; background-image: url('bgimg.jpeg'); background-size: cover; }#head{ text-decoration:underline; }input:required:invalid, input:focus:invalid, input:invalid { border-radius: 5px; border:soild 1px; }input:required:valid, input:valid { border-radius: 5px; }input[type='number'] { -moz-appearance:textfield; }input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; }.affix { top:0; width: 100%; z-index: 9999 !important; } .container-fluid{ margin-left:8% } .image{ float:left; margin-left:-9% } </style> </head> <body onload=display_ct();> <?php $success =0; if(!$link) die("error". mysqli_link_error()); if($_SERVER["REQUEST_METHOD"] =="POST"){ if(empty($_POST["name"])){ echo $name_error = "Enter the Name Properly !"; }else{ $name = $_POST["name"]; if(strlen($_POST["cno"]) != 10){ echo $cno_error = "Enter Valid Contact number"; }else{ $cno = $_POST["cno"]; if(empty($_POST["purpose"])){ $p_error = "Enter Valid Purpose"; }else{ $p = $_POST["purpose"]; date_default_timezone_set("Asia/Kathmandu"); $timein = date("H:i:s"); $rid = rand(100000,900000); $_SESSION["rid"] = $rid ; $date = date("Y/m/d"); // $comment = $_POST["comment"]; $day = date("d"); $month = date("m"); $year = date("Y"); $meet =$_POST["MeetingTo"]; $location=$_POST["location"]; $company=$_POST["company"]; //print_r($_FILES); //print_r($_POST); //exit; /******File upload******** */ $target_dir = "./uploads/"; $target_file = basename($_FILES["img"]["name"]); $target_file = str_replace(' ', '_',$target_file ); $img=$target_file; $target_file = $target_dir.$target_file; $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); // Check if image file is a actual image or fake image if(isset($_POST["submit_post"])) { $check = getimagesize($_FILES["img"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists // if (file_exists($target_file)) { // echo "Sorry, file already exists."; // $uploadOk = 0; // } // Check file size // if ($_FILES["img"]["size"] > 500000) { // echo "Sorry, your file is too large."; // $uploadOk = 0; // } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { 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["img"]["tmp_name"], $target_file)) { echo "The file ". htmlspecialchars( basename( $_FILES["img"]["name"])). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } //print_r($_FILES); //print_r($_POST); //exit; /*************** */ if(empty($name) || empty($cno) || empty($p) || strlen($cno)!=10) $displayError = "You have not entered the details correctly !"; else{ $sql = "INSERT INTO info_visitor(Name, Contact, Purpose, meetingTo, day, month, year, Date, TimeIN, ReceiptID,Status,registeredBy,location,company,img) VALUES ('$name','$cno','$p', '$meet', '$day', '$month', '$year', '$date', '$timein','$rid','ONLINE', '$user_','$location','$company','$img')"; if(mysqli_query($link,$sql)) $success =1; //redirection to the printing page. else echo "Error: " . $sql . "<br>" . mysqli_error($link);} //echo "<h4>You will be redirected to the home page after 10 secs !</h4> "; if($success == 1) header('location: user_profile.php'); } }}} ?> <!-- Navigation Menu --> <nav class="navbar navbar-default"> <div class="container-fluid"> <img class="image" src="krifylogo.jpeg" alt="logo" width="8%" > <div class="navbar-header"> <a class="navbar-brand" href="#" id = "li"><?php echo "Logged in as : ".$user_;?></a> </div> <ul class="nav navbar-nav navbar-right"> <li><a href="front.php" id = "li">Home</a></li> <li class="active"><a href="myform.php">Add Visitor</a></li> <li ><a id = "li" href="logoutform.php">Checked Out Visitors</a></li> <li><a id = "li" href="query_data.php">View Data</a></li> <li><a id = "li" href="logout.php">Logout</a></li> </ul> </div> </nav> <!-- time and date script --> <script type="text/javascript"> function display_c(){ var refresh=1000; // Refresh rate in milli seconds mytime=setTimeout('display_ct()',refresh) } function display_ct() { var date = new Date(); var hours = date.getHours() > 12 ? date.getHours() - 12 : date.getHours(); var am_pm = date.getHours() >= 12 ? "PM" : "AM"; hours = hours < 10 ? "0" + hours : hours; var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); time = hours + ":" + minutes + ":" + seconds + " " + am_pm; document.getElementById('t1').innerHTML = time; var x = new Date() var x1=x.getMonth() + 1+ "/" + x.getDate() + "/" + x.getFullYear(); document.getElementById('t2').innerHTML = x1; display_c(); } </script> <div style= "float:right; padding-right:8px;padding-top:10px;"> <p id = "timeDisplay" style="color:white"> <b>Time :</b> <span id="t1"></span> </p> <p id = "dateDisplay"style="color:white"><b> Date :</b> <span id="t2"></span></p> </div> <!-- <div style="margin-left:110px;padding-bottom:12px"> --> <div style="margin-left:110px;padding-bottom:12px"> <!-- <div class="container"> --> <!-- <h2 class="text-center">Add Visitor</h2> --> <p id = "redBoxSyndrome"><p> </div> <!-- <div class="container"> --> <!-- <div class="row" style="margin-left:1px"> <div class="col-sm-6"> --> <form class= "myForm" action= "<?php echo $_SERVER["PHP_SELF"];?>" method= "POST" enctype="multipart/form-data" id ="form" > <?echo $displayError ;?> <div class="container"> <h2 class="text-center">Add Visitor</h2><hr> <i class="fa fa-user fa" aria-hidden="true"></i> <label for="name" class="field"> Name :</label> <input autocomplete="off" class="form-control" type= "text" name ="name" placeholder= "Enter Visitor's Name." required id = "name" oninvalid="this.setCustomValidity(this.willValidate?'':'Name is required')" onblur="isEmpty('name')" onfocus="onfo('name')" data-toggle="popover" title="Popover Header" data-content="Some content inside the popover" data-trigger = "onfocus"/> <label for="cno" class="field"> <i class="fa fa-user icon"></i> Contact No. :</label> <span id = "span" style = "padding-bottom: 5px;float:right;"></span> <input autocomplete="off" class="form-control" type="number" pattern="[1-9]{1}[0-9]{9}" id = "ContactInfo" onkeyup = "Ccheck('ContactInfo')" onblur = "isEmpty('ContactInfo')" onfocus = "onfo('ContactInfo')" name="cno" placeholder="Enter Contact Number." required min="1000000000" max = "9999999999" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" type = "number" maxlength = "10" oninvalid="this.setCustomValidity(this.willValidate?'':'Enter correct Contact number please')" data-toggle="popover" title="Popover Header" data-content="Some content inside the popover" data-trigger = "onfocus"/> <label for ="prps" class="field">Purpose :</label> <input autocomplete="off" class="form-control" type="text" name="purpose" placeholder="Enter Purpose." required id = "Purpose" oninvalid="this.setCustomValidity(this.willValidate?'':'Enter your Purpose')" maxlength="30" onblur="isEmpty('Purpose')" data-toggle="popover" title="Popover Header" data-content="Some content inside the popover" data-trigger = "onfocus" /> <label for = "meetingTo" class="field">Meeting to :</label> <input autocomplete="off" class="form-control" type="text" required name = "MeetingTo" id = "meetingTo" placeholder="Whom will you meet ?" oninvalid="this.setCustomValidity(this.willValidate?'':'Whom do you want to meet ?')" maxlength="30" onblur="isEmpty('meetingTo')" data-toggle="popover" title="Popover Header" data-content="Some content inside the popover" data-trigger = "onfocus"/> <!-- <div class="form-group"> <label for = "comment">Comment :</label> <input autocomplete="off" class="form-control" type= "varchar" maxlength="30" name = "comment" height="50px" > <br> </div> --> <label for = "location" class="field">Location:</label> <input autocomplete="off" class="form-control" type="text" required name = "location" id = "location" placeholder="Where are you from ?" oninvalid="this.setCustomValidity(this.willValidate?'':'Where are you from ?')" maxlength="30" onblur="isEmpty('meetingTo')" data-toggle="popover" title="Popover Header" data-content="Some content inside the popover" data-trigger = "onfocus"/><br> <!-- <form action="upload.php" method="post" enctype="multipart/form-data"> Select image to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload Image" name="submit"> </form> --> <label for="office" class="field">Select Company:</label> <select name="company" id="off" class="field1"> <option selected>Choose Company</option> <option value="krify">Krify</option> <option value="avineon">Avineon</option> </select><br><br> <label for="img" class="field">Image:</label><input type="file" accept="image/*" name="img" class="file" required ><br> <div class="button"> <input id="submitme" type="submit" name="submit_post" class="btn btn-danger" value="Submit" onclick="return empty()"/> <input autocomplete="off" id="mydata" type="hidden" name="mydata"> </div> </div> </form> </div> </body> </html>