emn Posted June 26, 2008 Share Posted June 26, 2008 please help me I left with theree days to complete my project . what my Question is that How can I make a time control that the user must submit there assignment in time specfied that means when they submit out of the time the submition cancelled or denied. her is the conde that upload <?php $user = "root"; $pass = "root"; $db = "mydb"; $link = mysql_connect( "localhost", $user, $pass ); if ( ! $link ) die( "Couldn't connect to MySQL" ); mysql_select_db( $db, $link ) or die ( "Couldn't open $db: ".mysql_error() ); $uploadDir = 'C:/BlueJ/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $Fname=$_POST['txtFirstName']; $Sname=$_POST['txtSurname']; $SID=$_POST['txtid']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $query = "INSERT INTO upload2 (SID,Fname,Sname,name, size, type, path,Date ) ". "VALUES ('$SID','$Fname','$Sname','$fileName', '$fileSize', '$fileType', '$filePath',NOW())"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); echo "<br>Files uploaded<br>"; mysql_close( $link ); } ?> <h1>Thsnks For Submiting Your Assignment</h1> </body> </html> please if you have breif answer contact me arsgashaw@gmail.com Thanks for ur Help Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/ Share on other sites More sharing options...
KevinM1 Posted June 26, 2008 Share Posted June 26, 2008 What do you mean, exactly, by 'time specified'? Are you referring to an assignment's due date/time, or are you referring to a timeout situation, where if a user is accessing the file upload page for too long a time you'll boot them to another page? Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/#findComment-575339 Share on other sites More sharing options...
dannyb785 Posted June 26, 2008 Share Posted June 26, 2008 How much php do you know? Are you getting paid for this? If so, I think it's sad your company hired someone and is paying them who doesnt know php basics. Here's a quick way to do what you need. When they view the page with the form(or whatever is being timed), place 2 hidden variables. one variable is the time that they started the form($now = strtotime("now")) and the other is a encrypted hash of that date plus some other data unknown to the user(for example, $hash = md5($now."form") ). the encryption is so that someone can't duplicate the form with a later time in case they go over their time limit. So then, once the form is submitted, you compare the values. Firstly, that the difference between the $_POST data $now and the time at the point of submission(get another $submitted = strtotime("now") value right when the form is processed) is not greater than the amount of time given(allow 30 seconds or so leeway). Then, once it has been verified that the time in the $_POST value has not exceeded the time allowed, do a compare with the $hash value. Check that if($hash = md5($now."form") ) { sumitted properly } else { hack attempt } Hope that made sense Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/#findComment-575344 Share on other sites More sharing options...
KevinM1 Posted June 26, 2008 Share Posted June 26, 2008 How much php do you know? Are you getting paid for this? If so, I think it's sad your company hired someone and is paying them who doesnt know php basics. Is that really necessary? Also, by looking at the OP's posting history, it's pretty obvious that they're a student. Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/#findComment-575355 Share on other sites More sharing options...
dannyb785 Posted June 26, 2008 Share Posted June 26, 2008 How much php do you know? Are you getting paid for this? If so, I think it's sad your company hired someone and is paying them who doesnt know php basics. Is that really necessary? Also, by looking at the OP's posting history, it's pretty obvious that they're a student. 1) yes, it was necessary. Whether he's a student or a professional, getting answers from other people is never a good thing. 2) I dont check posters's history before commenting. If he's in class, he probably should've paid attention better. 3) besides, I gave the solution. I'm allowed to give him a hard time. Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/#findComment-575360 Share on other sites More sharing options...
Jabop Posted June 26, 2008 Share Posted June 26, 2008 1) yes, it was necessary. Whether he's a student or a professional, getting answers from other people is never a good thing. What is this forum for then? Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/#findComment-575369 Share on other sites More sharing options...
KevinM1 Posted June 26, 2008 Share Posted June 26, 2008 How much php do you know? Are you getting paid for this? If so, I think it's sad your company hired someone and is paying them who doesnt know php basics. Is that really necessary? Also, by looking at the OP's posting history, it's pretty obvious that they're a student. 1) yes, it was necessary. Whether he's a student or a professional, getting answers from other people is never a good thing. So, why are you here then? This is a place where people ask questions and seek answers. 2) I dont check posters's history before commenting. If he's in class, he probably should've paid attention better. Perhaps. Or perhaps they're just not suited to be a programmer, and, despite their efforts, are having trouble finding the solution. ASSuming why a person is requesting help speaks more about you than them, IMO. 3) besides, I gave the solution. I'm allowed to give him a hard time. What is this, high school? You don't get extra leeway just because you supplied some help. One does not excuse/negate the other. In any event, if you feel the need to respond, please take it to PMs. I have the feeling we've polluted this thread enough. Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/#findComment-575376 Share on other sites More sharing options...
dannyb785 Posted June 26, 2008 Share Posted June 26, 2008 Forgot... we have to be robots... we arent allowed to give opinions or feelings.. only answers Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/#findComment-575388 Share on other sites More sharing options...
KevinM1 Posted June 26, 2008 Share Posted June 26, 2008 Forgot... we have to be robots... we arent allowed to give opinions or feelings.. only answers No one's stopping you from having opinions or feelings. I am suggesting, however, that you employ some tact. Professionalism begins there. And, I'll let you in on something: I hate it when people who don't know what they're doing are paid by unsuspecting clients to do a project for them. It's unfair to the clients, who just paid a lot of money for shoddy work, and it's unfair to those of us in the profession, as it negatively affects our overall reputation. So, yes, I do get where you were coming from. That said, I'm not arrogant to ASSume that the people asking for help here are shady charletans scrambling to finish a project that's way over their ability, or students who didn't pay attention in class because they were partying, or stayed up all night playing TF2 with their buddies. And I'm certainly not going to look down on the people asking questions here. Why? Because I was a newbie too. I started coming here at least a year ago, if not earlier. I asked the simple questions. I didn't know what escaping meant. I thought sessions were completely mysterious. I could barely get a sticky form to work right. But the people here were both generally kind and helpful, and I progressed very quickly, in part because of them. And, you know what? I still ask questions on here. Things slip my mind. I have an OOP idea that I could design in several ways that I'd like feedback on. I ask about other languages/technologies I'm not entirely comfortable with. Does that make me inherently deficient, or 'bad' somehow? Should I be treated with less respect because I want a second opinion? Or because I had a brain fart? Or because I still may have trouble wrapping my head around something? tldr; You want to be a professional? Try acting like an adult first. Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/#findComment-575431 Share on other sites More sharing options...
emn Posted June 26, 2008 Author Share Posted June 26, 2008 I'm just a studen't I'm doing my own webpage the reason that I ask is becuse the examination time for me ia approach and because no time for me to read and do I choose asking some one. If not I try my best after exam. This is not for seeling or for examination purpose it was just for my knowlage if you are ok to answer for me I will wait if not stop disscution on me. Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/#findComment-575481 Share on other sites More sharing options...
emn Posted June 26, 2008 Author Share Posted June 26, 2008 What do you mean, exactly, by 'time specified'? Are you referring to an assignment's due date/time, or are you referring to a timeout situation, where if a user is accessing the file upload page for too long a time you'll boot them to another page? I'm referring date/time taht means after the dedline submition must fail for example if the deadline was jun10.12:30pm then after this time no submition is allowed Quote Link to comment https://forums.phpfreaks.com/topic/112077-please-help-me/#findComment-575486 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.