R
E
S
O
U
R
C
E
S
       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
_______________________

HOME
SEO, Google, Privacy
   and Anonymity
Browser Insanity
JavaScript
Popups and Tooltips
Free Website Search
HTML Form Creator
Animation
Buttons and Menus
Counters
Captchas
Image Uploading
CSS and HTML
PHP
AJAX
XPATH
Website Poll
IM and Texting
Databases—MySQL
   or Not MySQL
Personal Status Boards
Content Management
   Systems
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

Microcommunity (MC) Registration Script — Enter Questionnaire Data in Database

This script is called register-for-an-mc.php

The first PHP section is at the start of the script. First, we use the checkid.php script to ensure that the session id variable is set, and send the user to register-with-captcha.php if it is not. Then we define a named constant '_NODIRECTACCESS'. We include the config.php file (in the includes folder) which uses the PHP defined() function to check on this constant. If it is not set, we are thrown out of the config.php file like yesterday's trash. Then we put the POSTed value of 'username' into $U—we will be checking that it is set in a second. And we put the POSTed value of 'flag' into $flag.

Next we check if the session variables 'flag', 'username', and 'sessionid' are set and we make sure $U is set. If not, we are sent to the login-to-mc.php script.

We get the POSTed value of 'u' into $o and the POSTed value of 'g' into $q. $o now contains the 13 option arrays separated by | characters. Option arrays contain number values like 4 or 33 separated by commas. First we use the PHP explode() function to explode this stringified array of stringified arrays into 13 arrays and put them in the $opt[] array. Next we use a regular expression search and replace on each array element value (still stringified arrays) using the preg_replace() function. This limits data to numbers and commas even though that was done by JavaScript already—one can never have too much security.

Next we explode the 13 arrays into their separate numeric values in a loop, putting the results in the $opt2[] array. To be extra safe, we now use intval() to get the integer value of each number. They were only allowed to enter numbers from 0 to 99, so if the number is greater, we set it to 0. Now we dump duplicate values in each array and close the gaps where empty array element values are, using the array_keys() and array_flip() functions.

Now we stringify the resulting cleaned arrays using implode() and stick them each into $comma_separated_string and add commas to each end so searches work in the MySQL table searches using MC (Microcommunity) Search and Match. These stringified arrays we stick back into the $opt[] array elements, in a loop. This takes care of the select/option values.

Now we deal with the text input box values. They are in the stringified comma separated array of numbers (any of which may be from 0 to 99) sitting in the $q string. We explode() this into separate numbers and put these into the $howmany[] array. To be extra safe, we now use intval() to get the integer value of each number. We use the substr() function to get any number beginning with 0 and make the number into only the last number in the substring, which is usually 0 since starting with 0 should only be done by a user if he intends only a 0, but if he is weird enough to type 09 or 04, we fix it. If numbers are negative or more than 99 or not integers or not even set, we zero them.

Our data is ready to go into the MySQL table, as soon as we use the mysql_real_escape_string() function on them to make them safe to put in the db, even though they already are safe because we know they are simply numbers! One can never have too much security. We use MySQL's UPDATE . . . SET . . . WHERE combo to get the user's questionnaire data into the database. If all is well, we tell them and send them to Login to MC Search and Match Profile and Account Management. If it did not work because of connection problems or whatever, we tell them and send them to Login to MC Search and Match Profile and Account Management.

The script below is called: register-for-an-mc.php


<?php
include_once"checkid.php";
?>

<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>PHP Microcommunity (MC) Registration Script</TITLE>
<meta name="description" content="PHP MC Registration Script">
<meta name="keywords" content="PHP MC Registration Script,MC Registration Script,MC Registration,PHP Microcommunity Registration Script,Microcommunity Registration Script,Microcommunity Registration,add member,php,mysql,dhtml, DHTML">
</head>
<body>

<?php

define('_NODIRECTACCESS', TRUE);
include_once"includes/config.php";

$U=$_POST['username'];
$flag=$_POST['flag'];if(!isset($flag) || !isset($_SESSION['username']) || !isset($_SESSION['sessionid']) || !isset($U)){
echo '<script language="javascript">alert("Please login."); window.location="login-to-mc.php";</script>';
}else{

$signup_date=date("d-m-Y");
$o=$_POST['u'];
$q=$_POST['g'];

if(isset($o)){
$opt=explode("|",$o);
for ($i=0; $i<count($opt); $i++){
$opt[$i]=preg_replace('/[^0-9\\,]/', '', $opt[$i]);
$opt2=explode(",",$opt[$i]);
for ($j=0; $j<count($opt2); $j++){
$opt2[$j]=intval($opt2[$j]);
if($opt2[$j]>99){$opt2[$j]=0;}
}
$opt2=array_keys(array_flip($opt2));
$comma_separated_string = implode(",", $opt2);
$opt[$i]=",".$comma_separated_string.",";
}
}

if(isset($q)){
$howmany=explode(",",$q);
for ($i=0; $i<count($howmany); $i++){
$howmany[$i]=intval($howmany[$i]);
if (substr($howmany[$i],0,1)=="0"){$howmany[$i]=substr($howmany[$i],-1,1);}
if ($howmany[$i]<0 || $howmany[$i]>99 || !is_int($howmany[$i]) || !isset($howmany[$i])){$howmany[$i]=0;}
}
}

$males03=mysql_real_escape_string($howmany[0]);
$males47=mysql_real_escape_string($howmany[1]);
$males811=mysql_real_escape_string($howmany[2]);
$males1214=mysql_real_escape_string($howmany[3]);
$males1517=mysql_real_escape_string($howmany[4]);
$males1823=mysql_real_escape_string($howmany[5]);
$males2434=mysql_real_escape_string($howmany[6]);
$males3549=mysql_real_escape_string($howmany[7]);
$males5065=mysql_real_escape_string($howmany[8]);
$males6679=mysql_real_escape_string($howmany[9]);
$males80=mysql_real_escape_string($howmany[10]);
$females03=mysql_real_escape_string($howmany[11]);
$females47=mysql_real_escape_string($howmany[12]);
$females811=mysql_real_escape_string($howmany[13]);
$females1214=mysql_real_escape_string($howmany[14]);
$females1517=mysql_real_escape_string($howmany[15]);
$females1823=mysql_real_escape_string($howmany[16]);
$females2434=mysql_real_escape_string($howmany[17]);
$females3549=mysql_real_escape_string($howmany[18]);
$females5065=mysql_real_escape_string($howmany[19]);
$females6679=mysql_real_escape_string($howmany[20]);
$females80=mysql_real_escape_string($howmany[21]);
$childless=mysql_real_escape_string($howmany[22]);
$emptynesters=mysql_real_escape_string($howmany[23]);
$widows=mysql_real_escape_string($howmany[24]);
$widowers=mysql_real_escape_string($howmany[25]);
$married=mysql_real_escape_string($howmany[26]);
$livingtogether=mysql_real_escape_string($howmany[27]);
$separated=mysql_real_escape_string($howmany[28]);
$divorced=mysql_real_escape_string($howmany[29]);
$engaged=mysql_real_escape_string($howmany[30]);
$single=mysql_real_escape_string($howmany[31]);
$gaymales=mysql_real_escape_string($howmany[32]);
$lesbian=mysql_real_escape_string($howmany[33]);
$white=mysql_real_escape_string($howmany[34]);
$black=mysql_real_escape_string($howmany[35]);
$asian=mysql_real_escape_string($howmany[36]);
$hispanic=mysql_real_escape_string($howmany[37]);
$hawaiian=mysql_real_escape_string($howmany[38]);
$mixed=mysql_real_escape_string($howmany[39]);
$criminal=mysql_real_escape_string($howmany[40]);
$homeschooled=mysql_real_escape_string($howmany[41]);
$publicschools=mysql_real_escape_string($howmany[42]);
$privateschools=mysql_real_escape_string($howmany[43]);
$religiousschools=mysql_real_escape_string($howmany[44]);
$specialschools=mysql_real_escape_string($howmany[45]);
$allergies=mysql_real_escape_string($howmany[46]);
$chronic=mysql_real_escape_string($howmany[47]);
$mental=mysql_real_escape_string($howmany[48]);
$disabilities=mysql_real_escape_string($howmany[49]);
$ramps=mysql_real_escape_string($howmany[50]);
$willingeldercare=mysql_real_escape_string($howmany[51]);
$availableeldercare=mysql_real_escape_string($howmany[52]);
$needeldercare=mysql_real_escape_string($howmany[53]);
$willingchildcare=mysql_real_escape_string($howmany[54]);
$availablechildcare=mysql_real_escape_string($howmany[55]);
$needchildcare=mysql_real_escape_string($howmany[56]);
$Smoking_Drinking=mysql_real_escape_string($opt[0]);
$Preferred_Housing_Type=mysql_real_escape_string($opt[1]);
$Willing_to_relocate=mysql_real_escape_string($opt[2]);
$MC_type_sought=mysql_real_escape_string($opt[3]);
$Open_to_be_in_mixed_race_MC=mysql_real_escape_string($opt[4]);
$Sexuality=mysql_real_escape_string($opt[5]);
$Religious_Openness=mysql_real_escape_string($opt[6]);
$Religion=mysql_real_escape_string($opt[7]);
$Childrearing_Style_and_Preferences=mysql_real_escape_string($opt[8]);
$Pets=mysql_real_escape_string($opt[9]);
$Personal_Entertainment=mysql_real_escape_string($opt[10]);
$Housing_Interested_in_Common_Shared_Space_for=mysql_real_escape_string($opt[11]);
$Employment=mysql_real_escape_string($opt[12]);

$sql = "UPDATE mc_members SET
signup_date = '$signup_date',
males03 = '$males03',
males47 = '$males47',
males811 = '$males811',
males1214 = '$males1214',
males1517 = '$males1517',
males1823 = '$males1823',
males2434 = '$males2434',
males3549 = '$males3549',
males5065 = '$males5065',
males6679 = '$males6679',
males80 = '$males80',
females03 = '$females03',
females47 = '$females47',
females811 = '$females811',
females1214 = '$females1214',
females1517 = '$females1517',
females1823 = '$females1823',
females2434 = '$females2434',
females3549 = '$females3549',
females5065 = '$females5065',
females6679 = '$females6679',
females80 = '$females80',
childless = '$childless',
emptynesters = '$emptynesters',
widows = '$widows',
widowers = '$widowers',
married = '$married',
livingtogether = '$livingtogether',
separated = '$separated',
divorced = '$divorced',
engaged = '$engaged',
single = '$single',
gaymales = '$gaymales',
lesbian = '$lesbian',
white = '$white',
black = '$black',
asian = '$asian',
hispanic = '$hispanic',
hawaiian = '$hawaiian',
mixed = '$mixed',
criminal = '$criminal',
homeschooled = '$homeschooled',
publicschools = '$publicschools',
privateschools = '$privateschools',
religiousschools = '$religiousschools',
specialschools = '$specialschools',
allergies = '$allergies',
chronic = '$chronic',
mental = '$mental',
disabilities = '$disabilities',
ramps = '$ramps',
willingeldercare = '$willingeldercare',
availableeldercare = '$availableeldercare',
needeldercare = '$needeldercare',
willingchildcare = '$willingchildcare',
availablechildcare = '$availablechildcare',
needchildcare = '$needchildcare',
Smoking_Drinking = '$Smoking_Drinking',
Preferred_Housing_Type = '$Preferred_Housing_Type',
Willing_to_relocate = '$Willing_to_relocate',
MC_type_sought = '$MC_type_sought',
Open_to_be_in_mixed_race_MC = '$Open_to_be_in_mixed_race_MC',
Sexuality = '$Sexuality',
Religious_Openness = '$Religious_Openness',
Religion = '$Religion',
Childrearing_Style_and_Preferences = '$Childrearing_Style_and_Preferences',
Pets = '$Pets',
Personal_Entertainment = '$Personal_Entertainment',
Housing_Interested_in_Common_Shared_Space_for = '$Housing_Interested_in_Common_Shared_Space_for',
Employment = '$Employment' WHERE username = '$U'";
// Execute query
$res=mysql_query($sql);

mysql_close();

if($res){
echo '<script language="javascript">alert("Entries were made OK."); window.location="login-to-mc.php";</script>';
}else{
echo '<script language="javascript">alert("Entries were NOT made—something went wrong."); window.location="login-to-mc.php";</script>';
}
}
?>

</body>
</html>