Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <b>Select file to upload:</b></br></br>
- <img id="output"/ width="200" height="200" src="<?php echo $row['StdImage']; ?>">
- <input type="file" class="btn btn-primary" name="stdimage" accept="image/*" onchange="loadFile(event)">
- <?php include 'db.php';
- $id= $_POST['id'];
- if(isset($_POST['send'])){
- $Stdid_one = htmlspecialchars($_POST['txtID']);
- $Lname = htmlspecialchars($_POST['txtLname']);
- $Fname = htmlspecialchars($_POST['txtFname']);
- $Mname = htmlspecialchars($_POST['txtMname']);
- $Track = htmlspecialchars($_POST['track_type']);
- $track_id = htmlspecialchars($_POST['txttrackid']);
- $YearLvl = htmlspecialchars($_POST['txtgrade']);
- $Bday = htmlspecialchars($_POST['txtBday']);
- $BirthPlace = htmlspecialchars($_POST['txtBplace']);
- $MTongue = htmlspecialchars($_POST['txtMtongue']);
- $IP = htmlspecialchars($_POST['txtIp']);
- $Religion = htmlspecialchars($_POST['txtReligion']);
- $Street = htmlspecialchars($_POST['txtStreet']);
- $Barangay = htmlspecialchars($_POST['txtBrgy']);
- $Munic = htmlspecialchars($_POST['txtMunic']);
- $Province = htmlspecialchars($_POST['txtProv']);
- $Gender = htmlspecialchars($_POST['rbgender']);
- $Father = htmlspecialchars($_POST['txtfather']);
- $Mother = htmlspecialchars($_POST['txtmother']);
- $Guardian = htmlspecialchars($_POST['txtGuard']);
- $GuardRelation = htmlspecialchars($_POST['txtGuardRelation']);
- $Contact = htmlspecialchars($_POST['txtcontact']);
- $Remarks = htmlspecialchars($_POST['txtRemarks']);
- $formone= htmlspecialchars($_POST['chkfone']);
- $envelope= htmlspecialchars($_POST['chkenvelope1']);
- $onebyone= htmlspecialchars($_POST['chk1x1']);
- $birth= htmlspecialchars($_POST['chkbirth']);
- $twocopies= htmlspecialchars($_POST['chk2copies']);
- $ncae= htmlspecialchars($_POST['chkncae']);
- $goodmoral= htmlspecialchars($_POST['chkgoodmoral']);
- $formtwo= htmlspecialchars($_POST['chkform137']);
- $diploma= htmlspecialchars($_POST['chkdiploma']);
- $bothpic= htmlspecialchars($_POST['chkbothpic']);
- $except= htmlspecialchars($_POST['chkexcept']);
- $target_dir = "StdImage/";
- $file = basename($_FILES["stdimage"]["name"]);
- $target_file = $target_dir . basename($_FILES["stdimage"]["name"]);
- $uploadOk = 1;
- $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
- // Check if image file is a actual image or fake image
- if(isset($_POST["submit"])) {
- $check = getimagesize($_FILES["stdimage"]["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["stdimage"]["size"] > 500000000000) {
- 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["stdimage"]["tmp_name"], $target_file)) {
- echo "The file ". basename( $_FILES["stdimage"]["name"]). " has been uploaded.";
- } else {
- echo "Sorry, there was an error uploading your file.";
- }
- }
- $sql2 ="UPDATE tblstdpro SET StdImage='$target_file', Lname='$Lname', Fname='$Fname', Mname='$Mname', Track='$Track', track_id='$track_id', YearLvl='$YearLvl', Bday='$Bday', Birthplace='$BirthPlace', MTongue='$MTongue', IP='$IP', Religion='$Religion', Street='$Street', Barangay='$Barangay', Munic='$Munic', Province='$Province', Gender='$Gender', Father='$Father', Mother='$Mother', GuardianName='$Guardian', GuardRelation='$GuardRelation', Contact='$Contact', Remarks='$Remarks', form138='$formone', envelope1='$envelope', 1x1picture='$onebyone', psa='$birth', 2x2picture='$twocopies', ncae='$ncae', goodmoral='$goodmoral', form137='$formtwo', diploma='$diploma', bothpicture='$bothpic', alloriginal='$except' WHERE StdID ='$Stdid_one'";
- $db->query($sql2);
- header('location: StudentDatabase.php');
- }
- ?>
Add Comment
Please, Sign In to add comment