Home      Products & Services      Contact Us      Links

WebHatchers will design & develop your site for you.

Website Menu Heaven: menus, buttons, etc.

Send us your questions.

site search by freefind

SEO, Google, Privacy
   and Anonymity
Browser Insanity
Popups and Tooltips
Free Website Search
HTML Form Creator
Buttons and Menus
Image Uploading
Website Poll
IM and Texting
   or Not MySQL
Personal Status Boards
Content Management
Article Content
   Management Systems
Website Directory
   CMS Systems
Photo Gallery CMS
Forum CMS
Blog CMS
Customer Records
   Management CMS
Address Book CMS
Private Messaging CMS
Chat Room CMS
JavaScript Charts
   and Graphs

Free Personal Status Boards (PSB™)

Free Standard Free PSB

Free PSB Pro Version

Free Social PSB

Free Social PSB Plus (with Email)

Free Business PSB

Free Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement

Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

PHP Code to Prevent Duplicate Data Input (i.e., User Names or Members)

Let's start simple: Note that, in the following, we check through the Firstname data in the table to make sure the group member added is not a duplicate. If it is, we don't add the name, but give a warning message instead.



$res = mysql_query("SELECT Firstname FROM $B") or die(mysql_error());
while ($row = mysql_fetch_row($res)) {
array_push ($myArray, $row[0]);


if($dupe==1){$dupe=0;echo '<script language="javascript">alert("This name already exists.");</script>';}else{
----actually insert the new data into the table----}

Another simple example: After POSTing the inputted user name to PHP, we check out the table to see if the name given was already used. If so, we warn the user and do not molest the table. Note that one can look into a table to see if it exists, or get an array of the relevant data and look through it. Either way works.

$username = $_POST['username'];
$checkformembers = mysql_query("SELECT * FROM members WHERE username = '$username'");
if(mysql_num_rows($checkformembers) != 0){echo '<script language="javascript">alert("Username already in use. Please try again.")</script>;';
----actually insert the new data into the table----}

Sometimes there's a bug in the soup. PHP 5.2.11 has a dandy in its array_unique function which is supposed to dump any duplicate names, leaving only unique data. In our tests, it killed a good name now and then as well, leaving a data gap. Notice that we defined a couple of arrays and pushed the names POSTed to PHP into the first one. Then we ran the array_keys(array_flip()) function as a workaround for the broken array_unique function. It's not the function's purpose, but it worked, which is all that matters, though we're not all that sure why it works! When we put in duplicate names, the array_keys(array_flip()) function dumped them, and the
count() function detected fewer elements in the array and this caused us to give a warning message. The MySQL INSERT loaded the table with the cleaned array data—all standard stuff.


array_push ($myArray, $_POST['people'][$i]);
$myArray1=array_keys(array_flip($myArray));//array_unique has BUG!
if($num>$c){echo '<script language="javascript">alert("One or more duplicate names were deleted.");</script>';}

$j= $i + 1;
mysql_query("INSERT INTO $a (Firstname, ID, Status, Comment)

The following script deals with putting input into 3 different MySQL columns/fields, and the data must stay parallel from array to array. We start by putting all the POSTed data into arrays: $myArray, $myArray1 and $myArray2. Then we go through each element of the array, comparing it to all the elements with numerically higher key numbers. If two names are found to be the same, the element value is set to an empty string and a flag is set. If the flag is set, a message lets the user know that one or more duplicate names were deleted. Then the arrays are inserted into the MySQL table, except that the elements with the empty values are bypassed—not inserted anywhere. Note that this method of avoiding duplicates utilizes no functions like the array_keys(array_flip()) function or the broken array_unique function.



if($dupe==1){$dupe=0;echo '<script language="javascript">alert("One or more duplicate names were deleted.");</script>';}


if($b<>""){$j = $j + 1;mysql_query("INSERT INTO $a (Firstname, ID, Status, Comment, Username, Password)