Jump to content

nanie

Members
  • Posts

    10
  • Joined

  • Last visited

nanie's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I'm currently using date picker for selecting event date in my form codes. But I have problem when trying to insert to the database. The date picker display value as this, October 9th, 2013 I try to convert it using this code from another forum, $eventDate=$_POST['eventdate']; //check date format here before continuing. list($day,$month,$year)=explode('/',$eventDate); $timestamp=mktime(0,0,0,$month,$day,$year); $final_date=date('Y-m-d',$timestamp); echo $final_date; // to see the conversion and this is what i get back Warning: mktime() expects parameter 5 to be long, string given ..................... 1970-01-01 Please help me, I want to get this value -----> 09/10/2013
  2. @mac_gyver, here is my current code. <fieldset style="width:500px; background-color: #FFC"><legend align="center" style="font-size:24px">Upload file</legend> <p style="color:#F00"> ( Please take note to name your files accordingly and save as .pdf or .doc ) </p> <table width="809" cellpadding="2" cellspacing="2"> <tr> <td width="252"><label for="file">Acceptance Letter from Publisher:</label></td> <td width="541"><input type="file" name="file[]" id="acceptletter" onchange="checkFile(this)" required value=""></td> </tr> <tr> <td width="252"><label for="file">Turnitin Similarity Report :</label></td> <td width="541"><input type="file" name="file[]" id="turnitin" onchange="checkFile(this)" required value=""></td> </tr> <tr> <td width="252"><label for="file">Paper Indexing :</label></td> <td width="541"><input type="file" name="file[]" id="paperindex" onchange="checkFile(this)" > <br />/ Link : <input type="text" name="paperindexurl" size="30" /></td> </tr> <tr> <td width="252"><label for="file">Publisher's Reviewers Report :</label></td> <td width="541"><input type="file" name="file[]" id="reviewerReport" onchange="checkFile(this)" required value=""></td> </tr> <tr> <td width="252"><label for="file">Paper Submitted Version :</label></td> <td width="541">Link : <input type="text" name="submittedVersionurl" size="30" required value="" /></td> </tr> <tr> <td width="252"><label for="file">Published Conference Paper :</label></td> <td width="541">Link : <input type="text" name="confPaperurl" size="30" required value=""/></td> </tr> <tr> <td width="252"><label for="file">Camera Ready Paper (full) :</label></td> <td width="541"><input type="file" name="file[]" id="cameraReady" onchange="checkFile(this)" required value=""></td> </tr> <tr> <td width="252"><label for="file">Blind Paper (withour author info) :</label></td> <td width="541"><input type="file" name="file[]" id="blindPaper" onchange="checkFile(this)" required value=""></td> </tr> and the php still the same as the post above you.
  3. I still face the same problem..What else should I do to make it successful? Below is what I've change. if (isset($_FILES['file']) && !empty($_FILES['file'])) { $num_files = count($_FILES['file']); for($x =0; $x < $num_files; $x++) { $filename = $_FILES['file']['name'][$x]; $tempName = $_FILES['file']['tmp_name'][$x]; $allowed_ext = array ('doc', 'docx','pdf'); $file_ext = pathinfo($filename, PATHINFO_EXTENSION); if (($_FILES['file']['size'][$x] > 1048576) && (in_array($file_ext, $allowed_ext) == false)) { header('location: student_newSubmission.php?error=6'); exit(); } elseif ($_FILES['file']['error'][$x] == UPLOAD_ERR_OK) { $saveDirectory = "../upload/'.$matricNo.'/"; if (move_uploaded_file($tempName, $saveDirectory.$fileName)) { echo 'File Successfully Uploaded!'; } else { echo 'There was an error whilst uploading the file.'; } } } }
  4. Dear @Ch0cu3r and vinny42 , I've try the solution you guys give me. But once I submit, it will return to the page form and empty the field that I insert before. * I already commented the query part since I want to see if the files successfully uploaded.
  5. I have form where user have to fill in and upload several file. I plan to keep the files in upload folder under the ID of user (eg: ../upload/userID/filename) and save each dir of files in database so that it is easier (?) to retrieve later. But, since I am not familiar with the process, I kind of stuck with the codes. student_newSubmission.php (since it is long forms/codes, I put several only) <form action="student_newSubmission.php" method="post" enctype="multipart/form-data"> <table width="1023" cellpadding="2" cellspacing="2"> <tr> <td width="160"><strong>Full Name : </strong></td><td colspan="3"><?php echo $row['STDNAME']; ?><style="text-transform: uppercase" required value="" /></td> </tr> <tr> <td><strong>Sponsor : </strong></td><td width="374"><input name="sponsor" type="text" size="50" style="text-transform: uppercase"></td> <td><strong>Admission Date : </strong></td><td width="309"><?php echo $date; ?> <input type="hidden" name="admissionDate" id="admissionDate" value="<?php $date;?>" style="text-transform: uppercase" required value="" /></td> </tr> <tr> <td><strong>Matric No : </strong></td><td width="374"><?php echo $row['MATRICNO']; ?> <input type="hidden" name="matricNo" id="matricNo" value="<?php echo $row["MATRICNO"]; ?>" style="text-transform: uppercase" required value="" /></td> <td><strong>Email Address :</strong></td><td width="309"><?php echo $row['EMAIL']; ?> </td> </tr> . . . . . </table> . . . . <fieldset style="width:500px; background-color: #FFC"><legend align="center" style="font-size:24px">Upload file</legend> <p style="color:#F00"> ( Please take note to name your files accordingly and save as .pdf or .doc ) </p> <table width="809" cellpadding="2" cellspacing="2"> <tr> <td width="252"><label for="file">Acceptance Letter from Publisher:</label></td> <td width="541"><input type="file" name="file" id="acceptletter" onchange=checkFile(this) required value=""></td> </tr> <tr> <td width="252"><label for="file">Turnitin Similarity Report :</label></td> <td width="541"><input type="file" name="file" id="turnitin" onchange=checkFile(this) required value=""></td> </tr> <tr> <td width="252"><label for="file">Paper Indexing :</label></td> <td width="541"><input type="file" name="file" id="paperindex" onchange=checkFile(this) > <br />/ Link : <input type="text" name="paperindexurl" size="30" /></td> </tr> <tr> <td width="252"><label for="file">Publisher's Reviewers Report :</label></td> <td width="541"><input type="file" name="file" id="reviewerReport" onchange=checkFile(this) required value=""></td> </tr> </table></fieldset> this is what I already try... edit from what I found in the forum. if(isset($_POST['submit']) && !empty($_POST['submit'])) { $sponsor = $_POST['sponsor']; $admissionDate = $_POST['admissionDate']; $matricNo= $_POST['matricNo']; . . . $paperindexurl= $_POST['paperindexurl']; $submittedVersionurl= $_POST['submittedVersionurl']; $confPaperurl=$_POST['confPaperurl']; if (isset($_FILES['file']) && !empty($_FILES['file'])) { $num_files = count($_FILES['file']); for($x =0; $x < $num_files; $x++) { $filename = $_FILES['file']['name'][$x]; $tempName = $_FILES['file']['tmp_name'][$i]; $allowed_ext = array ('doc', 'docx','pdf'); $file_ext = strtolower(end(explode('.', $filename))); if ((filesize($filename) > 1048576) && (in_array($file_ext, $allowed_ext) == false)) { header('location: student_newSubmission.php?error=6'); exit(); } elseif ($_FILES['file']['error'][$x] == UPLOAD_ERR_OK) { $saveDirectory = '../upload/'.$matricNo.'/'; if (@move_uploaded_file($tempName, $saveDirectory . $fileName)) { echo 'File Successfully Uploaded!'; } else { echo 'There was an error whilst uploading the file.'; } } } } $query= "INSERT INTO submission VALUES(seq_subID.nextval, '$matricNo', '$sponsor', '$admissionDate', '$programme', '$sem', '$field', '$supervisor', '$cosupervisor', '$papertitle', '$author', '$conftitle', '$organizer', '$address', '$tel', '$venue', '$confDate', '$fee' , .................."; $parse= oci_parse($conn, $query)or die(oci_error()); $exe= oci_execute($parse); if ($exe == 1) { header('location:homeStudent.php'); echo '<script type="text/javascript">'; echo 'alert ("Successfully upload your form!")'; echo '</script>'; } else { echo '<script type="text/javascript">'; echo 'alert("There was an error while uploading your form. Please try again.")'; echo '</script>'; } } and here is submission table.. subID NUMBER(4) NOT NULL, matricNo VARCHAR2 (10)NOT NULL, sponsor VARCHAR2(10), admissionDate DATE NOT NULL, programme VARCHAR2(10), sem VARCHAR2(4) NOT NULL, field VARCHAR2(10) NOT NULL, supervisor VARCHAR2(50) NOT NULL, cosupervisor VARCHAR2(50) NOT NULL, papertitle VARCHAR2(50) NOT NULL, author VARCHAR2(150) NOT NULL, conftitle VARCHAR2(50) NOT NULL, organizer VARCHAR2(20), orgaddress VARCHAR2(50), orgtel VARCHAR2(20), venue VARCHAR2(30), confDate DATE, fee NUMBER(10), file1 VARCHAR2(30) NOT NULL, file2 VARCHAR2(30) NOT NULL, file3 VARCHAR2(30), indexurl VARCHAR2(30), file4 VARCHAR2(30) NOT NULL, submitversionurl VARCHAR2(30) NOT NULL, confpaperurl VARCHAR2(30), file5 VARCHAR2(30) NOT NULL, file6 VARCHAR2(30) NOT NULL); So far, is it correct what I am doing.? From the code above, nothing happen when I try to submit. Not even check the file. Please anyone show me the way.. I really don't know how to proceed.
  6. Thanks Guru! It works very well! I appreciate your help. My problem with the script solved. Now I'm trying to figure out on how to handle this multiple upload in the server-side. There are 6 files user have to upload. and will be store under one table named submission (field name: file1, file2 and so on) If possible please guide me with this too..
  7. > Before this I put different name for different file, but when I faced problem on how to handle multiple uploads, some people in a forum suggest to use array to grab the files. So I have to use the same name for each files (file[ ]) . Now I get confused. > I'll try what you have suggested. > The file still will be checked later on server-side. This is just to alert user to insert the correct file so that it is easier to check later. Since I have a long form, handling it might takes time and imagine if user upload wrong file.
  8. HI. Can anyone help me. I've change the code here and there to make it works but failed. The problem is there is 2 files to be uploaded, but only the second one will display alert message, while the first one will just receive any file. EG: I try select the same file for both. But the first one does not respond while the second part respond that it is not the acceptable file extension. Here is the code. <script> function checkFile() { var node_list = document.getElementsByTagName('input'); for (var i = 0; i < node_list.length; i++) { var node = node_list[i]; if (node.getAttribute('type') == 'file') { var sFileName = node.value; var sFileExtension = sFileName.split('.')[sFileName.split('.').length - 1]; var iFileSize = node.files[0].size; var iConvert=(node.files[0].size/10485760).toFixed(2); } if (sFileExtension != "pdf" && sFileExtension != "doc" && sFileExtension != "docx" && iFileSize>10485760) { txt="File type : "+ sFileExtension+"\n\n"; txt+="Size: " + iConvert + " MB \n\n"; txt+="Please make sure your file is in pdf or doc format and less than 10 MB.\n\n"; alert(txt); } } } </script> my form, <input type="file" name="file" id="confirm" onchange="checkFile()"> <input type="file" name="file" id="approveletter" onchange="checkFile()"> Please help me...
  9. Thank you Muddy Funster for noticing it. I feel ashamed that I can't notice it.
  10. Hi, I don't know how to solve this problem. Please help me. <?php if(isset($_COOKIE['ID_site']) && isset($_COOKIE['Pass_site'])) { $_SESSION['id'] = $_COOKIE['ID_site']; $_SESSION['password'] = $_COOKIE['Pass_site']; if(isset($_SESSION['id'])) { $id = $_SESSION['id']; $pass = $_SESSION['password']; echo $id; $query2 = oci_parse($conn,"SELECT * FROM user1 WHERE id ='".$id."'")or die(oci_error()); $check2 = oci_execute($query2); echo $check2; while($info2=oci_fetch_array(query2,OCI_ASSOC+OCI_RETURN_NULLS)) //the error come from this line { echo $info2[0]; //if the cookie has the wrong password, they are taken to the login page if (($pass != $info2['PASSWORD']) || ($info2['ROLE'] != 'admin') ) { header('Location: index.php?error=4'); } //otherwise they are show the admin home else { ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.