Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 21 Aug 2011, 15:43
just.b.jealous just.b.jealous is offline
 
Join Date: Sep 2009
In need of a bit of help.. PHP/MySQL related

I've hit a wall and I'm in need of a bit of help. I think it's in more in the way of PHP/SQL/JS,.. meaning I need to use those instead of vbulletin be able to do it. I think. First let me explain what I'm trying to do..

First off, I'm on a non-vbulletin page- I'm just to have a link that takes you to a 'email us' that is only clickable by your IP address twice every hour. I'm hosting an hourly contest allowing 2 entries per hour, but am having trouble on finding how to restrict the link after the 2 clicks. Also- members are not required to be logged in..

I would think I'd have to have a SQL table for IP compered to link? Record amount into table as well as time/date?
Reply With Quote
  #2  
Old 21 Aug 2011, 16:56
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
You mean two clicks per hour on the clock, so for instance they click twice at 1:59 then twice at 2:01, but not again until 3:00? Then yeah, I think I'd make a table with ip, time of last click, count this hour, and total count columns. Updating is a little tricky since you could get two or more near-simultaneous clicks from the same ip, so a "read, check the value, write a new record" sequence could end up with unexpected results.

You probably know that more than one user could appear to come from the same ip, and one user can come from multiple ips, so it can be a problem trying to use an ip address to award the prize (like if two users clicked from the same ip, who wins?). Not to mention the fact that if they don't have to be logged in you have to do the matching of user to ip somehow.

Last edited by kh99; 21 Aug 2011 at 17:11. Reason: typo
Reply With Quote
  #3  
Old 21 Aug 2011, 17:06
just.b.jealous just.b.jealous is offline
 
Join Date: Sep 2009
More or less- using it as a safe guard from users-overclicking. Our site doesn't have problems with bots or anything. Also helps filter unneeded mail.

Could you (well do you mind) helping me with what code I would need to accomplish this? I could read from the code what tables would need to be created- I just need help with actually implementing the checks on the page and what not... Total newb- yeah I know. Oh and I know the ins and out of my hosting/cpanel so you wouldn't have to hold my hand the whole way

--------------- Added 21 Aug 2011 at 17:23 ---------------

I've just been told about trying:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

But yeah- I'm not to sure what to actually do with it,..


My coding where it needs to be implementing is simple- just not sure how to wrap myself around it- and I'm even unsure of the guys tables, lol now that I'm looking at that code again- how's it even enter the persons last details, wthm. ^.^


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Last edited by just.b.jealous; 21 Aug 2011 at 17:24.
Reply With Quote
  #4  
Old 21 Aug 2011, 17:27
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by just.b.jealous View Post
I've just been told about trying:....
Yeah, I can see that. That's a little different because it checks for two clicks in any given hour period, not just hours by the clock. And I guess it just involves appending records to the table, which is good. The vbulletin "views" counting works that way - there's a process that runs hourly to roll up the counts into another table and clear the table with the records.

Was that someone here? To be honest, while I could come up with something that would work, I'm not really a database person.
Reply With Quote
  #5  
Old 21 Aug 2011, 17:33
just.b.jealous just.b.jealous is offline
 
Join Date: Sep 2009
No it came off stackoverflow but lacked any other explanation other then- yeah I'd use this. How? Which way? Where's it go? Does it need tables? How do I get info inserted? I'm stumblin' around in the dark ^.^.

You said:
"That's a little different because it checks for two clicks in any given hour period"

That would work perfect but how do I actually use it?
Reply With Quote
  #6  
Old 21 Aug 2011, 17:43
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Well, with that scheme you'd have one table with just ip and time, and when someone clicked you'd do the check then if it passes, append to the table. I just reread your first post and now I realize that you don't want to count up total clicks there or use it to award the prize, just to control how often someone clicks (you *did* say that before...).

I don't know exactly how your "email us" page works, so I'm not sure where to tell you to put the check. If you're submitting a form you could check when the form is submitted. If you're just trying to control access to that page you could have a php script that does the check and either displays the page or an error message. (I may be able to post some actual code when I understand it a little more).
Reply With Quote
  #7  
Old 21 Aug 2011, 17:58
just.b.jealous just.b.jealous is offline
 
Join Date: Sep 2009
Thanks for helping me out by the way--

Yup- just to control how many times they click it in an hour..

Main page is index.html- this page has the link needing to be limited... regular page with a button on it.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.



clicking it takes you to ./forms/form1.html (this page is a simple email form which submits/post to form1.php:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

After emailing- it takes them to the homepage.
Reply With Quote
  #8  
Old 21 Aug 2011, 18:09
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Alright, I have a couple more questions - are you trying to definetely keep someone from submitting more than two emails per hour? Because that's harder, once someone gets the email form page they can look at it and see what it's submitting, then bypass any checks you do before they get to the form. But if you just want to discourage the "honest" people from submitting too many times, then it's not that hard.
Reply With Quote
  #9  
Old 21 Aug 2011, 18:18
just.b.jealous just.b.jealous is offline
 
Join Date: Sep 2009
Nah, not worried about emails too, and I think I'll change the "hidden" .php and make it sorta sporadic, update the html to repoint to it. (and so on.) but I don't think it will be needed once they can't click the button more then twice an hour from the same IP. All in all it's not tooo important as the prizes are virtual items to begin with , so yeah. But man- thanks for helpin me out... I'm not sure how to connect to the DB in the file or anything really man. I'm pretty new to SQL.

--------------- Added 21 Aug 2011 at 18:20 ---------------

I would assume to put some kind of check into the email form to make sure the user came from front page and didn't just go directly to the form? How would I go about that one?

--------------- Added 21 Aug 2011 at 19:05 ---------------

I'd say it would be best to make the form.php do the actual checks- (not the button itself?) so no email is sent if it's failed (or even be accessed by that IP until the hour is up),- then make it so you have to be referred from the front page to the form (so they can't just click the button), Users have no idea who's being mailed- just that it's the admin. And if they're willing to go through alllll that hassle for some free virtual items- I guess they earned it, ^.^.
Reply With Quote
  #10  
Old 21 Aug 2011, 19:09
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Actually, I'm wrong again - you just need to do a check in your php file and you're OK. (To be honest, I'm being distracted by other things...). (ETA: And I just read what you added to your post above - I guess you figured out that I was wrong...).

I'm working on it now, give me a few....

one more question though: can you include your vb config.php file in the form1.php, or would you rather just set the database access info again in that file?
Reply With Quote
  #11  
Old 21 Aug 2011, 19:22
just.b.jealous just.b.jealous is offline
 
Join Date: Sep 2009
I'd rather set the info in the file itself- it'll have it's own DB. It's all good- you're actually taking the time to help, it's much appreciated my man.
Reply With Quote
  #12  
Old 21 Aug 2011, 20:00
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
OK, this is kind of bare bones but hopefully it will help:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Note the instructions for creating the table (which you have to do manually) are at the top. And you need to set your db info. This doesn't have the email code in there, but you can see where you should insert it (pretty much just copying the code form the existing script, or maybe put it in a function. This doesn't really handle errors except printing them out, I don't really know how you'd want to handle them.
Reply With Quote
  #13  
Old 21 Aug 2011, 20:04
just.b.jealous just.b.jealous is offline
 
Join Date: Sep 2009
Hell yeah, much obliged. Won't have a chance to try it out yet (gotta head to work).. So lites crosses our fingers.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 15:47.

Layout Options | Width: Wide Color: