
swfcfan4
Members-
Posts
13 -
Joined
-
Last visited
Never
Everything posted by swfcfan4
-
To test to see if it works, I have changed the mktime to 30th November 2009, and I tried what you said and still it doesn't work. Why is it going wrong?
-
I really hope that someone can help me. (Sorry to post again)
-
Ok so I have had another go on this using dates instead and have come up with: if ($_SESSION["previousVisit"]) { // tell user they have already voted and cannot vote again } else if ( date("d/m/Y") < $finish ) { // take the vote from html web form using $_POST // thank user for voting and display their choice } else { // tell user voting has finished and that their vote will not count // display the result of the vote to the user } $finish = mktime(11, 15, 0, 12, 2, 2009); $_SESSION["previousVisit"] = time(); the problem is even if the finish is set to the 2nd December, the user is getting the message that its too late to vote. Any ideas anyone of whats wrong?
-
So I need to start the session then create a variable called $start which would be the start time of the poll e.g. start_session (); $start = time() Then the session variable I had e.g. $_SESSION["previousVisit"] = time() and then compare these in my If statement?
-
OK so I currently have this in my code updated with what you gave me: session_start (); $_SESSION["previousVisit"] = time(); if ($_SESSION["previousVisit"]) { // tell the user they have already voted } else if (strtotime('+1 week', $_SESSION["PreviousVisit"]) >= time()) { // display vote result } else { // take their vote from html page from $_POST // dsiplay message to user with their selection } Is this correct? I feel like its a little wrong. Hope you can guide me in the right direction.
-
Ok thanks, I'm just a little unsure about the timestamp though, do i need to create one first? is it possible for you to give me an example?
-
I am storing my results in a text file. So would what you said in the post above mine work still?
-
It is after a week that the poll started. I have the following in my code already: session_start (); $_SESSION["previousVisit"] = time(); if ($_SESSION["previousVisit"]) { // tell the user they have already voted } else { // take their vote from html page from $_POST // dsiplay message to user with their selection } would I need to put yuor if statement above my first if or put it in the else part? Thanks for the help you have given me so far. This is the only thing that has been bothering me for a couple of days.
-
Well I need a time limit of a week so that people can vote and not see the results until after a week. I am interested to know what the $expired does though if you could tell me. Is it defined already in php or would I need to declare it? Thanks for your help.
-
Hi everyone. I have a php program which uses a session cookie to check if a user of my website has voted more than once. The problem is, after the deadline, of say a time limit of a week to vote, I need to display the result of the vote and I am having trouble setting a time limit on the session cookie to expire after a week so I can display the vote count. I am aware of the function ini_set("session.gc_maxlifetime", "TIME LIMIT HERE"); but am unsure how I can use this to make the session cookie display a vote count after the deadline has passed. Any help would be good. And I thank you in advance if you can help solve my problem.
-
Help to display a vote count after a deadline has passed.
swfcfan4 replied to swfcfan4's topic in PHP Coding Help
Actually, going back and looking at my code, I have realised where I went wrong, and the code you gave me worked! Thanks very much. -
Help to display a vote count after a deadline has passed.
swfcfan4 replied to swfcfan4's topic in PHP Coding Help
Sorry to say that what you gave me did not work it is outputting results like this: Alan ShearerMichael OwenKevin PressmanDavid GinolaAlan Shearer - 1 Is there any thing else that can be done? -
Help to display a vote count after a deadline has passed.
swfcfan4 posted a topic in PHP Coding Help
Hi everyone! I am new to this forum, heard if was a great forum so I thought I'd join and ask a question so here goes! I am having a little problem thinking about how to display a vote count for a web poll after a deadline has passed. I have created the web form in HTML and used the POST method to retrieve the vote from the HTML web form. I have saved the voter's selection into a text file and have a warning in place if they have voted before using a session cookie. My only problem is how to display the final result of the vote in a vote count. I can give you a sample of my code: session_start (); $_SESSION["previousVisit"] = time(); if ($_SESSION["previousVisit"]) { echo "NO VOTING TWICE!!!"; } else { $sels = $_POST['selection']; echo "Every vote counts, you selected"; echo "$vote"<br />"; } $filePointer = fopen ("Num_of_votes.txt", "a"); if ($filePointer) { $selct = $_POST['selection']; $nln = "\n" ; $line = $selct .$nln ; fputs ($filePointer, $line); } fclose ($filePointer); Any help would be very much appreciated and I thank you in advance if you are able to help me with my problem.