PHP - Limit 2 Accounts/users Per Ip
Hello all,
I am a total noob in php and some VIP asked me to make something simple for our clubhouse; A page where users can submit/input 2 codes through a textbox and store it in a database. There are 2 things i want: max 2 submits/inputs per IP(to prevent abuse)(ip stored in database). $ip = $_SERVER['REMOTE_ADDR']; $check = mysql_query("select * from table where ipcolumn='$ip'"); if (mysql_num_rows($check) > 0) $insertip = "insert into table (ipcolumn) values ('$ip')"; And i wanna catch the error when an user put in a code lower than 5 characters. not something like: if ($textarea == ""){ This is where i am so far. new.php <?php include 'includes/config.php'; mysql_select_db($mysql_database, $con); $sql="INSERT INTO users (code, code2) VALUES ('$_POST[code]','$_POST[code2]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }else{ header ("Location: /thanks.php"); } ?> includes/config.php <?php $mysql_host = "myhost.com"; $mysql_database = "mydb"; $mysql_user = "myuser"; $mysql_password = "mypass"; $con = mysql_connect($mysql_host,$mysql_user,$mysql_password); if (!$con) { die('Could not connect: ' . mysql_error()); } ?> sql.sql -- -- Table structure for table `users` -- CREATE TABLE `users` ( `code` varchar(30) collate latin1_general_ci NOT NULL, `code2` varchar(32) collate latin1_general_ci default NULL, `timestamp` int(11) unsigned NOT NULL, PRIMARY KEY (`code`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; index.html <form action="new.php" method="post" onsubmit="return onSubmitButton();"> <input value="" id="something" class="LoginForm-Input" name="code1" size="34" style="float: left;">[/code] Similar TutorialsUnless buffer overflows or breaking out of code to perform a new command are problems that have been solved.... I am trying to figure out the proper PHP method for setting a boundary on a variable within a script. I have this variable $name which is fed a value from $_POST['name'] from a form field. Now this form field is limited in the HTML to accept only 20 characters, but someone could easily edit the form or outgoing post data. So I want to know how to limit the variable size in the script. In other languages it could be something like this: var name(20). So how do I do that in PHP? Hello
I am trying to work out how many regular users I have to my site and how long those users tend to be users..
So, I have a table that logs every time a user visits my site and logs in, it stores the date / time as a unix timestamp and it logs their user id.
I started by getting the id's of any user who logs in more than 5 times in a specified period, but now I want to extend that...
SELECT userID as user, count(userID) as logins FROM login_history where timestamp > UNIX_TIMESTAMP('2014-06-01 00:00:00') and timestamp < UNIX_TIMESTAMP('2014-07-01 00:00:00') group by user having logins > 5; hi all, i have a page which lists all of my registered users from the mysql database but i want the ability to edit an account, here is my list users code (just shown the appropiate code and not the rest): Code: [Select] <?php require ('../secure/connect.php'); $sql = "SELECT * FROM users ORDER BY user_level ASC"; $result=mysql_query($sql); echo '<table width="80%" border="0" cellspacing="5" cellpadding="0">'; echo ' <tr> <th><p align="left">User ID:</th> <th><p align="left">User Level:</th> <th><p align="left">Username:</th> <th><p align="left">User Title:</th> <th><p align="left">Email:</th> <th><p align="left">Actions:</th> </tr>'; while($rows=mysql_fetch_array($result)){ ?> <tr> <td><?php echo $rows['userid']; ?></td> <td><?php echo $rows['user_level']; ?></td> <td><?php echo $rows['username']; ?></td> <td><?php echo $rows['user_title']; ?></td> <td><?php echo $rows['email']; ?></td> <td><a href="edit_account.php?id=">Edit Account</a></td> </tr> <?php } ?> this lists my users nicely, as you can see i put it a edit account action at the end with a empty id= because that may be a way of doing it but im not sure what else to do or if there is a better way of doing it. any help would be great! I am having a problem with my User Log-In... When a User creates an account on my website, an e-mail is sent that looks like this... Quote Congratulations! Your account has been created, and a confirmation e-mail sent to: "john.doe@mail.com" Please click on the link in that e-mail to activate your account. Then when they click on the link, it takes them to my 'activate.php" page which updates the User's record by removing the Activation Code. The "Activation" seems to work fine. However, the problem that I just realized is that I am doing nothing to prevent someone from Registering, NOT Activating his/her account, but still being able to Log In?! I guess what I need to do when a User logs in is check to be sure that the "activation_code" column is NULL, right? Here is a snippet of my Log In script... if (empty($errors)){ // Valid form data. // ************************ // Find Member Record. * // ************************ // Connect to the database. require_once(WEB_ROOT . 'private/mysqli_connect.php'); // Build query. $q = 'SELECT id, first_name FROM member WHERE email=? AND pass=?'; // Prepare statement. $stmt = mysqli_prepare($dbc, $q); // Bind variables to query. mysqli_stmt_bind_param($stmt, 'ss', $email, $pass); // Execute query. mysqli_stmt_execute($stmt); // Store results. mysqli_stmt_store_result($stmt); // Check # of Records Returned. if (mysqli_stmt_num_rows($stmt)==1){ // Member was Found. // Bind result-set to variables. mysqli_stmt_bind_result($stmt, $memberID, $memberFirstName); // Fetch record. mysqli_stmt_fetch($stmt); // Set Session variables. $_SESSION['memberID'] = $memberID; $_SESSION['memberFirstName'] = $memberFirstName; $_SESSION['loggedIn'] = TRUE; What would be the best way to fix this? Thanks, Debbie Hello! I want to build a script to basically keep track of the number of hosting accounts that are currently on each server. I have roughly 30 servers (root access, WHM, cPanel) that I would like to be able to track all of from a single page. Could someone help/point me in the right direction/offer any input? thanks! much appreciated! How can i detect someone who is using proxy and has 2 or more accounts on my website?Or anyway, the important thing for me it is that they dont cheat because i have a competition and its forbidden to have 2 or more accounts.
I am looking to see if I could use one of the paypal features to pay two diffierent account from a single transaction and does paypal does that automatically?.. I was checking the immediate payment for a third party from the express checkout but I don't know that much about it. Does anyone knows how to achieve this? Not sure if this is related to the thread but I do think that it is
I have a server using Apache
I tried to set up an email doing something@domain.com
I tried to point the MX records to the server
It still doesn't work, if I try to send anything to that email, I get a response saying "Recepient not found" smtp.secureserver.net... blah
Since I changed the MX records to something other than smtp.secureserver.net, I don't know why I still get that message
I was trying to save on spending the $3.95 or whatever for email with office 365 haha
Any help would be greatly appreciated
Still, logically one question is obvious, don't I need to specify the storage location of the email... ? I mean there was an option in Cpanel where I created the email account but I don't understand what that means... did it configure a storage location? I don't know...
This probably is not an appropriate thread section for this question
Edited by greenace92, 04 December 2014 - 05:18 AM. Hi guys, This is very important. The supervisor of my system wants to close accounts which contain zero balances for long time periods. There is a separate page contains ID and Account Number.This is included in a form and a "close account" button is there. When he clicks on that button the relevant record should be deleted from all tables which include that ID. The table structure looks like this. There are 4 account types which contain same fields. savings_investment(ID,account_type,full_name_balance,interest,customer_id) I want full coding of this scenario. Thanks, Heshan Hey everybody,
I'm a noob when it comes to PHP so I have a few questions.
I'm in the planning stages for a new website and I need it to do something but I'm not sure how. People would have to log into my website in order to make a purchase and I need to be able to link their account with the software they bought. Think of it like a bit like Steam, you buy the game and its right there in your library.
The way I see it working is they buy their software and when they look in their profile they see a list of the stuff they've bought and have the ability to open it.
The Ecommerce company I'm looking to sign up with to make the transactions and keep the money side of it in order (FastSpring) don't have a way of tracking user purchases so I have to come up with a way of doing my end.
What I would like to know is what language is best to do this? I assume PHP would be the best especially considering the website itself is likely to be built in WordPress.
Secondly does anybody have any links to articles, videos or tutorials on this as I have not been able to find any all afternoon. I know they're going to be out there but I'm not having any luck finding them
Thanks for your time
I just discovered that I have a major security flaw with my website. Anyone who logs in to the website can easily access other users information as well as delete and edit other users information just by changing the ID variable in the address bar. I have user ID Session started on these pages but still people can do anything they like with other users information just by editing the address bar. For example if your logged in in the address bar of www.mywebsite.com/delete_mystuff.php?id=5 and change the "5" say to a "9" then you will have access to user#9 information. Every important page that I have has this code: Code: [Select] session_start(); if (!isset($_SESSION['user_id'])) { // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/index.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } else { //Else If Logged In Run The Script if((isset($_GET['id'])) && (is_numeric($_GET['id']))) { $id = (int) $_GET['id']; } elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { $id = (int) $_POST['id']; } else { echo ' No valid ID found, passed in url or form element'; exit(); } What am I doing wrong? Please help if you know how to correct this. Many thanks in advance. I'm making a checklist. One table holds the list with IDs. There are about 224 rows, each with its own ideas. Now I have another table to hold user accounts. When you create an account, it shows you a fresh new checklist that you need to start checking off. Could anyone please share techniques so I can have multiple accounts have their own list they need to check off? (ie, when a new person creatures a new account they should have their own list with NOTHING checked) The only way I can think of doing this is making 224 fields for the user account with the IDs of the checklist table to check if I checked it or not. Surely there's an easier way? Thanks I would like my website to show which users are logged in. Is there a simple way of retrieving all session ids from the server that have been allocated and are active in order to do this? I know this could lead to faulty information, but would appear to be the simplest and reliable. Thanks. I'm working on a new user submission form and I was wondering whether it's safe to send a confirmation letter to the user using their hashed password as their confirmation code? Since this is a hashed password it can't be decrypted (I believe), the password is useless because it's always hashed before login so it can't be used to login to the system, it's only being emailed to the user who's account is tied to the account, and it would save me the option of having to store a confirmation code field in my DB. Is this safe? Hello,
I designed (not coded) a finance application for windows phone 8.1 and one of the features that would be ideal is to copy your login steps in order to access your bank account automatically. Yes this does not sound safe or sane. How do I convince app users to use it?
Anyway, I want this access. My rationale is that, the login information would be stored locally and if my phone was hacked then what's the loss in my login steps being hacked... they would probably be encrypted anyway but...
The goal is to be able to open up a clone browser (eg. within the app) and then every step that you take, enter url, login credentials, security questions, pages accessed... the clone browser remembers and then later on as part of the app's function, it would automatically update your balances. I mean I suppose you could come up with the formulas, cash advance fees, interest rates, etc... but at the same time this doesn't seem to be a fixed thing... eg. hard to keep track and get the exact cent amount... or maybe I'm just bad at math
Some things in mind bitmapping, key strokes, string search, number search...
Anyway scripting came to mind, not sure if php or python but
Any thoughts?
Retrieve Pages, Ads, Leads from multiple facebook accounts with Graph API - Help needed I need Delete Duplicate Email Records That Are Attached To One Account But Can Be Found In Multiple Accounts I have a table, consumer_mgmt. It collects consumer information from various forms. These forms are available through different pages that are part of a business package. A business can offer these signups to gather names and emails from consumers for various types of specials they may offer. So a consumer my be in the consumer_mgmt table 5, 10, 15 times for that particular business. But, that consumer may be in the consumer_mgmt table multiple times for a different business. So multiple times for multiple businesses. I need to remove duplicates for each business account so the consumer is only the consumer_mgmt only once for each business. There are approximately 15,000 rows currently in the consumer_mgmt table. I'm not sure where to begin on the logic. Since there are multiple business accounts that the emails are attached to, would one have to build a case for each loop? im using the floowing code to pull all alerts from the database. as you can see i have 3 types of alertsd. Profile alerts, forum alerts and topic alerts. They are sorted and placed on the screen under their respective header. However i want to limit it so it only displays 4 of each type of alert. I cant use LIMIT in the query because that would limit all alerts meaning only 4 alerts in total would show up and i just need to limit each alert type. any ideas? $alert_query = $link->query("SELECT a.a_aid, a.a_alert_type, a.a_time_alerted, a.a_fid, a.a_poster, a_alert_read, a.a_tid, c.f_name as cat_name, f.f_fid, f.f_name, t.t_name, u.u_avatar, u.u_avatar_cropped FROM ".TBL_PREFIX."alerts as a LEFT JOIN ".TBL_PREFIX."forums as f ON (f.f_fid = a.a_fid) LEFT JOIN ".TBL_PREFIX."topics as t ON (t.t_tid = a.a_tid) LEFT JOIN ".TBL_PREFIX."forums as c ON (c.f_fid = f.p_id) LEFT JOIN ".TBL_PREFIX."users as u ON (u.u_username = a.a_poster) WHERE a.a_user_name = '$user_name' ORDER BY a_time_alerted ") or die(print_link_error()); $alert_info = $alert_query->fetchAll(); $pm_alert_list = ''; $num_pm_alerts = 0; $num_forum_alerts = 0; $num_topic_alerts = 0; foreach($alert_info as $key => $val) { $alert_info[$key]['a_alert_read'] == 0 ? $color = '#f5dfaf' : $color = '#f4f4f4'; // if alert is a profile message alert if($alert_info[$key]['a_alert_type'] == 1) { $pm_alert_list .= '<dd style="background:'.$color.';" class="alert" id="alert-'.$alert_info[$key]['a_aid'].'"><p class="alert_intro">'; $pm_alert_list .= '<input type="checkbox" class="pm_checkbox" id="pm_checkbox-'.$alert_info[$key]['a_aid'].'" />'.profile_link($alert_info[$key]['a_poster']).' posted on your wall</p>'; $pm_alert_list .= '<p class="alert_time"> on '.asf_date($alert_info[$key]['a_time_alerted'],'full').'</p>'; $pm_alert_list .= '</dd>'; $num_pm_alerts++; } if($alert_info[$key]['a_alert_type'] == 2) { $forum_alert_list .= '<dd style="background:'.$color.';" class="alert" id="alert-'.$alert_info[$key]['a_aid'].'"><p class="alert_intro">'; $forum_alert_list .= '<input type="checkbox" class="pm_checkbox" id="pm_checkbox-'.$alert_info[$key]['a_aid'].'" /><strong><a href="'.$config['asf_root'].'category/'.create_url($alert_info[$key]['cat_name']).'/forum/'.create_url($alert_info[$key]['f_name']).'">'.$alert_info[$key]['f_name'].'</a></strong> has a new topic</p>'; $forum_alert_list .= '<p class="alert_time"> '.asf_date($alert_info[$key]['a_time_alerted'],'full').'</p>'; $forum_alert_list .= '</dd>'; $num_forum_alerts++; } if($alert_info[$key]['a_alert_type'] == 3) { $topic_alert_list .= '<dd style="background:'.$color.';" class="alert" id="alert-'.$alert_info[$key]['a_aid'].'"><p class="alert_intro">'; $topic_alert_list .= '<input type="checkbox" class="pm_checkbox" id="pm_checkbox-'.$alert_info[$key]['a_aid'].'" /><strong><a href="'.$config['asf_root'].'category/'.create_url($alert_info[$key]['cat_name']).'/forum/'.create_url($alert_info[$key]['f_name']).'/topic/'.create_url($alert_info[$key]['t_name']).'">'.$alert_info[$key]['t_name'].'</a></strong> has a new post</p>'; $topic_alert_list .= '<p class="alert_time"> '.asf_date($alert_info[$key]['a_time_alerted'],'full').'</p>'; $topic_alert_list .= '</dd>'; $num_topic_alerts++; } } Hello friends, if i've database table (mytable) has the following ids 1 2 3 4 5 6 and i want to get it with limit the first (1 to 3 ) only Code: [Select] $sql ="select * from mytable LIMIT 3"; this will show the first 3 (1,2,3) how then i write code that shows which is after 3 so it shows me 4 5 6 and if there any way i can say Code: [Select] $sql ="select * from mytable LIMIT (first half of ids)"; and (shows 1,2,3..ect till half) Code: [Select] $sql ="select * from mytable LIMIT (second half of ids)"; will (shows 4,5,6...ect till end) thank you This code works fine without the LIMIT 5, but it lists all the results. With the LIMIT Code: [Select] $query = 'SELECT * FROM wp_playerRank WHERE year="2011" LIMIT 5 ORDER BY rankClass ASC'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) { Here is the error I'm getting: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/jwrbloom/public_html/resources/players/rank2011_top5.php on line 26 |