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

MC Scheduler Management—Add a Care Needer

This script is called Add-a-Care-Needer.php

This utility is used to append the MySQL care needers table with a name. It adds the new care needer unless it detects that the field value already exists in the MySQL table.

The MC Scheduler is a caregiving scheduler for kids and/or elders. It contains the application utilities listed above. There is a utility called Setup Scheduler which lets you enter the names of the kids and/or elders needing care, and this Add a Care Needer utility lets you add more. Then it saves 3 files, one with the names of the care needers, one with the names of the caregivers, and one with a blank 2-week schedule. The View Scheduler utility lets you see the schedule, with no editing.

Before you use the Edit MC Scheduler option on the main menu, you'll need to get everyone together and figure out the caregiving schedule which lasts two weeks, so you'll need to figure out who cares for whom. You'll see that the schedules are set up as half hour slots and cover 24 hours a day. When you first see the schedule it will be set up with two X characters for all slots for the whole two weeks. X means "no care needed." For most MCs or families or groups (or even babysitting co-ops), the slots from 9 p.m. to 7 a.m. will be left with the Xs (parents are "watching over" their kids by sleeping in their own rooms—but still available), so you'll need to set up caregivers for 7 in the morning to 9 at night, mostly, since after that we assume the kids and care-needing elders will be asleep. Of course, also in the daytime will be Xs for when kids are at school or soccer practice or music lessons or preschool or whatever. So even if kids are sleeping over at a different home in your group, it is assumed there are parents sleeping in a nearby room, available as needed.

The reason there are Xs over Xs and—once you fill in the slots—names over names, is that the primary caregiver is on top and the secondary caregiver is on the bottom. See Why Register for an MC? to see why caregiver choice is important—the kid should be able to choose which of these two people will care for him/her. The kid starts with the primary caregiver and chooses to switch to the secondary caregiver if he wants to. The best place for the caregiving is a space set aside for it. This allows kids to play with other kids in their group, and the chosen (primary or secondary) caregiver will be there, playing with or talking with the kids as they wish or—more often—reading a book or doing something on a computer while the kids play together.

The editing of the schedule is simple. Select one of the caregivers from the dropdown menu in Edit MC Scheduler, and click him or her wherever appropriate on the schedule either on top, as the primary caregiver or on the bottom as the secondary caregiver. Do this for the whole two weeks and then go on to the next caregiver from the dropdown menu, until all slots are filled as needed. Yes, the first scheduling meeting will be a long one. Bring snacks!

Even though we designed the Scheduler for MCs (microcommunities), there would be nothing to stop babysitting co-ops from using it. Most co-ops think in terms of one caregiver for so many kids. The American Academy of Pediatrics and the American Public Health Association recommend child-caregiver ratios of 3:1 for children from birth to 12 months, 4:1 for children from 13 to 30 months, 5:1 for children from 31 to 35 months, 7:1 for 3-year-olds, and 8:1 for 4-year-olds and older. We agree, but feel that there needs to be secondary caregivers as well—for backup. Like we say, the kids should be able to choose which of these two people will care for them.

On to the code: This utility is used to append the MySQL care needers table with a name. It adds the new care needer unless it detects that the field value already exists in the MySQL table. The first 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 put the session variable 'username' into $U—we will be checking that it is set in a second. 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.

Next we check if the session variables 'groupname', 'username', and 'userid' are set. If not, we are sent to the login-to-mc.php script. We make sure $U is still equal to the session variable 'username', that it is not an empty string, and that it's at least 6 characters long or . . . you guessed it . . . the login script. We make sure the session id is set and send them away if not.

The reason we are willing to use JavaScript to send visitors away is that none of our scripts will work without it. One cannot register, enter data, get from here to there, etc., in most of our scripts without it. What serious web surfer turns off JavaScript? In case you were not aware, many sites rely totally on JavaScript for menu functioning and some of their scripts. And what about data entry? In case you didn't know it, it is a huge convenience for the user because of the way it does input validation. A good site will validate in JavaScript as well as PHP. When the JavaScript data validation script catches unacceptable input, it can simply send focus to the input box where the bad input happened, the user fixes it, and the script is submitted. But if JavaScript is disabled, the user gets sent to PHP data validation which catches the bad data and sends the user back to the input form to redo all input from scratch. The JavaScript data validation script will not make a user restart, if well written. If you have experienced restarting data entry in a long form due to an accidental character, you know exactly what we are talking about. It's maddening! And a good way to get users to surf away from your site forever. If a person turns off THE major browser scripting language just because of a miniscule chance of encountering a scripting exploit on some web page, rather than installing good anti-spyware and anti-virus software, his Internet experience overall will be greatly diminished. Many sites have no alternatives to their script-enabled navigation, so the person is 100% screwed on those sites. But even on those with the alternative, it is always cumbersome and awkward. Besides, the scheduler editing script requires AJAX which in turn needs JavaScript, and if you cannot edit the schedule, it's useless. Point taken?

Next we deal with JavaScript. The validateit() function checks the text entered into the HTML form, using the search() method and a regular expression. And it makes sure you have entered 5 to 30 characters and only letters and spaces and hyphens in the name. If you goofed, the function returns false and the submitting will fail to happen and the cursor will stay in the input box because of the focus() method. Otherwise it returns true.

Now we go to PHP. We POST the submitted person in from the HTML form and put him or her in $p. Then we use the preg_match() function to see if correct characters were entered—illegal ones result in a JavaScript message "Please enter 5 to 30 letters and spaces and hyphens for name." and a page refresh. Note that we need to enclose this JavaScript-containing PHP validator in brackets {} and use the else control structure after it to make it work right. Otherwise, PHP that comes after the JavaScript alert on the page will still run. We use the mysql_real_escape_string() function to keep the name data safe.

The MySQL MAX() function finds the highest value in a column. We use this +1 for the N field when INSERTing the new record in the table. Next we SELECT the new username from the table as a validation precaution, since any care needer names except ones already in the table are valid. Since you are just now entering it, it should not be there. It it is, we give the alert that "Name already exists." and then refresh the page so the user can try a new care needer name. Do not omit the else after it to make it work right, as discussed above. And finally, we use INSERT INTO and append this new name to the table and give an alert. The success alert gets an else after it but the failure alert doesn't. It does not need an else after it since no PHP that we don't want to run comes lower in the script.

This script below is called Add-a-Care-Needer.php

if (!isset($_SESSION['groupname']) || !isset($_SESSION['userid']) || !isset($_SESSION['username']) || $_SESSION['username']<<BR>
$U || !isset($U) || $U=="" || strlen($U)<6 || !isset($_SESSION['sessionid'])){echo '<script language="javascript">alert("Please login, then select MC Scheduler."); window.location = "login-to-mc.php";</script>';}

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add a Care Needer</title>
<meta name="description" content="Add a Care Needer">
<meta name="keywords" content="Add a Care Needer,MC,MC Scheduler">

<script language="javascript">

function validateit(){
var ck_name = /^[A-Za-z- ]{5,30}$/;
if (document.myForm.name.value.search(ck_name)==-1)
{document.myForm.name.value='';alert("Please only enter letters and spaces and hyphens for names, and enter 5 to 30 characters.");document.myForm.name.focus();return false;}
return true;}


<style type="text/css">
.j {position:absolute;top:40px;left:-1900px;width:10px;}

<body SCROLL="auto" BGCOLOR="#FFFFFF">

<div class="d">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;<a HREF="http://www.thebiganswer.info/MC-Scheduler.php">Return to MC Scheduler Management</a><BR></div>


if (!isset($p)){
echo '<div style="position:absolute;left:250px;top:132px;z-index:99;width:500px;height:60px">
<form name="myForm" id="form" method="post" onsubmit="return validateit()" action="Add-a-Care-Needer.php" style="background-color:#ccc;width:500px;">
<center><table width="500px" height="60" border="1" align="center">
<td>Care Needer: </td>
<td><input name="name" type="text" size="30" maxlength="30" value=""></td>
<td><input name="submit" type="submit" id="submit" value="submit"></td>


$p = strip_tags($p);
if (!preg_match("/[A-Za-z- ]{5,30}$/",$p)) {
echo '<script language="javascript">alert("Please enter 5 to 30 letters and spaces and hyphens for name."); window.location = "Add-a-Care-Needer.php"; </script>';}else
$nr = mysql_query("SELECT MAX(N) FROM $a") or die(mysql_error());
while ($row = mysql_fetch_array($nr)){
$sq=mysql_query("SELECT * FROM $a WHERE username='$p'") or die(mysql_error());
if(mysql_num_rows($sq) > 0){echo '<script language="javascript">alert("Name already exists."); window.location = "Add-a-Care-Needer.php";</script>';}else
{$sql=mysql_query("INSERT INTO $a (N,username)
VALUES('$N','$p') ") or die(mysql_error());
if ($sql){echo '<script language="javascript">alert("Name added."); window.location = "Add-a-Care-Needer.php";</script>';}else{'<script language="javascript">alert("Name NOT added."); window.location = "Add-a-Care-Needer.php";</script>';}}}}

echo '<div class="t" align="center">Add a Care Needer, '.$U.'</div>';