3raser Posted November 14, 2009 Share Posted November 14, 2009 Alright, I know how to make sessions. But, I want to make a session that allows me to stop users from voting for a site for another 1 hour and then the session goes away. How would I be able to do that? Link to comment https://forums.phpfreaks.com/topic/181458-creating-a-session/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 14, 2009 Share Posted November 14, 2009 That's not something you could do with a session. All the person would need to do is drop the session id and get a new session and they could vote again. To do what you state would require that you remember the last time they voted using a database of some kind (mysql, flat-file...) Link to comment https://forums.phpfreaks.com/topic/181458-creating-a-session/#findComment-957226 Share on other sites More sharing options...
3raser Posted November 14, 2009 Author Share Posted November 14, 2009 That's not something you could do with a session. All the person would need to do is drop the session id and get a new session and they could vote again. To do what you state would require that you remember the last time they voted using a database of some kind (mysql, flat-file...) I can do that, but my question is, how? I have more then one voting things. http://www.webmasters.webatu.com - How do I store IP's in just one row?... Link to comment https://forums.phpfreaks.com/topic/181458-creating-a-session/#findComment-957229 Share on other sites More sharing options...
trq Posted November 14, 2009 Share Posted November 14, 2009 That's not something you could do with a session. All the person would need to do is drop the session id and get a new session and they could vote again. To do what you state would require that you remember the last time they voted using a database of some kind (mysql, flat-file...) I can do that, but my question is, how? I have more then one voting things. http://www.webmasters.webatu.com - How do I store IP's in just one row?... You wouldn't use 1 row. For each poll store an id identifying which poll was voted on, another id identifying the user and a timestamp to see when they last voted. Link to comment https://forums.phpfreaks.com/topic/181458-creating-a-session/#findComment-957234 Share on other sites More sharing options...
3raser Posted November 14, 2009 Author Share Posted November 14, 2009 I SERIOUSLY don't understand what you mean...any examples you could give me? Here is my vote.php page: <?php require("style.css"); $dbhost = $dbuser = $dbpassword = $db = $ip = $_SERVER['REMOTE_ADDR']; $pname = $_GET[project]; //connecting to the database $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); $query = mysql_query("SELECT * FROM info WHERE pname='$pname'"); $numrows = mysql_num_rows($query); if ($numrows!=1) die("<content>Project does not exist!</content>"); $points = mysql_query("UPDATE info SET numbers = numbers + 1 WHERE pname='$pname'"); echo "Voted for $pname! <br /><br />"; ?> Forum BBCode: <br /><br /><textarea rows="10" cols="32">[url=http://"http://www.webmasters.webatu.com/vote.php?project=<?php echo $pname; ?>"][img=http://www.webmasters.webatu.com/testing.php?pname=<?php echo $pname; ?>][/url]</textarea> Link to comment https://forums.phpfreaks.com/topic/181458-creating-a-session/#findComment-957235 Share on other sites More sharing options...
trq Posted November 14, 2009 Share Posted November 14, 2009 I SERIOUSLY don't understand what you mean...any examples you could give me? I SERIOUSLY don't know how it could be put any simpler. Link to comment https://forums.phpfreaks.com/topic/181458-creating-a-session/#findComment-957238 Share on other sites More sharing options...
3raser Posted November 14, 2009 Author Share Posted November 14, 2009 I SERIOUSLY think someone else should help then. Link to comment https://forums.phpfreaks.com/topic/181458-creating-a-session/#findComment-957240 Share on other sites More sharing options...
slyte33 Posted November 14, 2009 Share Posted November 14, 2009 Just create a table in the DB named 'votes', then create these rows: id int 11 auto_increment users_id int 11 timeleft int 11 then select those from the DB where users_id = sessions id they are logged into or whatever then if timeleft >= time() + 3600; Link to comment https://forums.phpfreaks.com/topic/181458-creating-a-session/#findComment-957242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.