473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populate an Array from MYSQL and check

155 New Member
I have a website that requires a visitor to register in order to make a post. I have one or two users that are violating the terms and every day I'm having to delete them. They just re-register, sometimes using a new email address (always a gmail account though).

I want to create a database and enter banned email addresses. Then I want to populate an array using these banned email addresses. When someone tries to register I want to check to see if the email address they're using is in the banned email array, if so the registration will fail.

I can make the database and put the information in it OK, but I'm not familiar with arrays and don't know how to write the code to populate an array from a database or how to write the query to check to see if the email is in the array. Can someone help me with this?

Thanks
Apr 6 '09 #1
1 2386
Markus
6,050 Recognized Expert Expert
You would just do a simple SELECT query using a WHERE clause.

Expand|Select|Wrap|Line Numbers
  1. $email = "bademail@gmail.com";
  2.  
  3. // Query searches the database for an entry that has matching emails.
  4. $sql = "SELECT `email` FROM `bad_emails` WHERE `email` = '{$email}' LIMIT 1";
  5.  
  6. $res = mysql_query( $sql );
  7.  
  8. if ( mysql_num_rows( $res ) > 0 )
  9. {
  10.     die ( "Banned email." );
  11. }
  12. else
  13. {
  14.     // good email.
  15. }
  16.  
However, they could just sign up with a new email address. You might look into banning IP addresses, although even that isn't reliable.

- mark.
Apr 6 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2943
by: mike | last post by:
I'm fairly green with javascript, and have been looking everywhere for an example of how to load data from a mysql db into javascript arrays. For a little background on what I'm trying to do, any suggestions would be greatly appreciated... I have a table in a mysql db that data for banners, each record includes the image name of the banner...
4
2704
by: Japhy | last post by:
Hello, I'm am pulling data from a mysql db and want to use the data to populate a <ul. Here are relavent parts of my code : $wohdate = mysql_result($wohRS,$wohndx,woh_date); $woh_display .="<li>".$wohdate."</li>" ; $TemplateText = Replace($TemplateText,"@$wohdisplayndx@",$woh_display);
2
24452
by: George | last post by:
Is there a fast way to transfer an Excel range to an array? Example: Excel range is E2:E300 Dim person() as string Thanks, George
11
17634
by: Zordiac | last post by:
How do I dynamically populate a string array? I hope there is something obvious that I'm missing here Option Strict On dim s() as string dim sTmp as string = "test" dim i as integer s(i)=new string(test) Above line gives - error implicit conversion string to 1-dim array of
2
2913
by: rjames.clarke | last post by:
I want to check if any of the items in a PHP array exist in a MySQL table. What is the best way to do this with making repeated calls to the database for each item? Actual application is: I have an array (in PHP) of serial numbers of units about to be shipped. I want to check the ship record (a table in a MySQL database) to check if that...
12
1865
by: Martien van Wanrooij | last post by:
I have been using for a while a class to create photo albums. Shortly, an array of photo's is declared, initially they are shown as thumbnails, by clicking on a thumbnail a larger photo is shown and there are links to the thumbnail list but also to the previous and next photo as the function remembers which position the photo has got in the...
9
1836
by: IamIan | last post by:
I'm using an array to store map features (name, lat, lon, caption, etc), from which the user can then select an individual feature. The problem is that when thousands of features are stored in the array, looping over the entire array looking for a match is SLOW. So I'm running a hash in parallel, where every time a feature is pushed onto...
3
9128
by: OliveOyl3471 | last post by:
In Visual Basic.NET 2003, how do you populate a two dimensional array from a text file? I know how to check file existence, open the file for read, etc. I just can't get it to read more than one record from the file into the array. I have declared a 2 dimensional, 12 row, 2 column array named strVenues(11,1) in the public section of the form....
4
6488
by: TechnoAtif | last post by:
Hi ALL I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be retrieved using list/menu box. When i check only a single checkbox to insert the checked category ,selecting that category through list box gives out the...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.