I can't get a program to post fields from form submitted...Desperate

I am pulling hair out and can not get new php program to use fields from the form.

Need someone to look it over and show me where I am wrong. I have written own debugger to look at the $_POST[‘c_patname’] field from form and it shows as blank…?.. This is my 4th program and the first 3 run great with no issues.

Earlier programs create/insert/update tables but now I can create the table but when I insert a record the fields are all empty. Further checking seems to show my form fields are all blank… how can that be?

Not sure how to send the program parts to get a quick look by someone who will instantly see what the problem is.

Please contact me for my email and phone number… asap would be nice.

Thanks in advance for help to get me going again, Jerry

You would probably get more help if you POST your code here on the site. PDF coverts many characters like underscores etc and is hard to work with.

It’s really difficult to read your PDF, but when you are updating a table if post values you need to check if the query that you are doing the include are calling all the fields that are required. I did not find the GetSelfScript() in your code too, this way i can’t analyse what could be the problem in your post.

I can not see how to unload the code but here it comes…


<?PHP

//  vo_cases_mstr.php

require_once("./include/vo_config.php");

if(isset($_POST['submitted']))
{
   if($fgmembersite->BuildCase())
   {
      $fgmembersite->RedirectToURL("vo_cases.php");
   }
}

?>

<!DOCTYPE html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<style>
    @import url(style/vo.css);
</style>
<style>
#fg_membersite fieldset
{
   background-color: #FFE5CC;
   /*width:550px;*/
   width:99%;
   padding:2px;
   border:1px solid #000;
-moz-border-radius:10px;
-webkit-border-radius:10px;
-khtml-border-radius:10px;
border-radius:10px;   
}
#fg_membersite .container
{
   margin-top:2px;
   margin-bottom:2px;
}
#fg_membersite .short_explanation
{
   text-align:left;
   font-family:Verdana, sans-serif;
   font-variant:small-caps;
   font-size:0.9em;
   font-weight:bold;
   color:red;   
}
.ros_it
{
   text-align:center;
   font-family:Verdana, sans-serif;
   font-variant:small-caps;
   text-decoration:underline;
   font-size:0.9em;
   font-weight:bold;
   color:#000;   
}
.ros_itnl
{
   text-align:center;
   font-family:Verdana, sans-serif;
   font-variant:small-caps;
   font-size:0.9em;
   font-weight:bold;
   color:#000;   
}
.label_it 
{
font-size:0.8em;
font-weight:bold;
/*color: #000;*/
}
</style
</head>
<body class="dynamic">
 
<div class="page_id">Case Management: Maintain Case Master</div>

<center>

<!-- Form Code Start -->
<div id='fg_membersite'>
<form id='BuildCase' action='<?php echo $fgmembersite->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>

<fieldset>

<!--legend>Control</legend-->

<input type='hidden' name='submitted' id='submitted' value='1'/>

<table width="100%" border="0">
<tr>
<td align="left">
<span class='short_explanation'>control</span>
</td>
</tr>
</table>

<input type='text'  class='spmhidip' name='<?php echo $fgmembersite->GetSpamTrapInputName(); ?>' />

<span class='error'><?php echo $fgmembersite->GetErrorMessage(); ?></span>

<table width="100%" border="0">
<tr>

<td align="center">
<span class='container'>
<label for='c_element'>Element:</label>
<select name="c_element" size="1"  style="height:20px;font-size:0.8em;padding:0px;">
<option value="">Please select...</option>
<option value="Cardiology">Cardiology</option>
<option value="Dermatology">Dermatology</option>
<option value="Endocrinology">Endocrinology</option>
<option value="Gastroenterology">Gastroenterology</option>
<option value="Geriatrics">Geriatrics</option>
<option value="Gynecology">Gynecology</option>
<option value="Hematology">Hematology</option>
<option value="Infectious Disease">Infectious Disease</option>
<option value="Nephrology and Urology">Nephrology and Urology</option>
<option value="Neurology">Neurology</option>
<option value="Obstetrics">Obstetrics</option>
<option value="Ophthalmology and Otolaryngology">Ophthalmology and Otolaryngology</option>
<option value="Pediatrics">Pediatrics</option>
<option value="Psychiatry">Psychiatry</option>
<option value="Pulmonology">Pulmonology</option>
<option value="Rheumatology and Orthopedics">Rheumatology and Orthopedics</option>
<option value="Surgery">Surgery</option>
</select>
</span>
</td>

</tr>
</table>

<hr width="355px" color="#000">

<table width="100%" border="0">
<tr>

<td align="left">
<span class='container'>
<label for='c_patname'>Name:</label>
<input type="text" name="c_patname"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:380px" maxlength="40">
</span>
</td>

<td>
<span class='container'>
<label for='c_patgndr'>Gender:</label>     
<select name='c_patgndr' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="M">M</option>
<option Value="F">F</option>
</select>
</span>
</td>

<td>
<span class='container'>
<label for='c_patage'>Age:</label>
<input type="text" name="c_patage" style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:27px" maxlength="3">
</span>
</td>

<td>
<span class='container'>
<label for='c_patethncty'>Ethnicity:</label>
<input type="text" name="c_patethncty" style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:14px" maxlength="1">
</span>
</td>

<td align="right">
<span class='container'>
<label for='c_patdate'>Date:</label>
<input type="text" name="c_patdate" style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:72px" maxlength="8">
</span>
</td>

</tr>
</table>
</fieldset>

<fieldset>
<table width="100%" border="0">
<tr>

<td align="left">
<span class='container'>
<label for='c_cc'>CC:</label>
<input type="text" name="c_cc"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:380px" maxlength="40">
</span>
</td>

<td>
<span class='container'>
<label for='c_td'>Td:</label>
<input type="text" name="c_td" style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:200px" maxlength="20">
</span>
</td>

<td align="right">
<span class='container'>
<label for='c_lmpdate'>LMP:</label>
<input type="text" name="c_lmpdate" style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:72px" maxlength="8">
</span>
</td>

</tr>
</table>
</fieldset>

<fieldset>
<table width="100%" border="0">
<tr>

<td align="left">
<span class='short_explanation'>hpi:</span>
</td>

</tr>
</table>

<table width="100%" border="0">
<tr>

<td align="left">
<span class="label_it">- Onset:</span>
</td>

<td align="right">
<input type="text" name="c_hpi_onset"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>

<tr>
<td align="left">
<span class="label_it">- Location:</span>
</td>

<td align="right">
<input type="text" name="c_hpi_loc"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>

<td align="left">
<span class="label_it">- Duration:</span>
</td>

<td align="right">
<input type="text" name="c_hpi_dur"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>

<tr>
<td align="left">
<span class="label_it">- Characterization:</span>
</td>

<td align="right">
<input type="text" name="c_hpi_char"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>

<td align="left">
<span class="label_it">- Alleviate:</span>
</td>

<td align="right">
<input type="text" name="c_hpi_alle"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>

<tr>
<td align="left">
<span class="label_it">- Aggravate:</span>
</td>

<td align="right">
<input type="text" name="c_hpi_aggr"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>

<td align="left">
<span class="label_it">- Radiating:</span>
</td>

<td align="right">
<input type="text" name="c_hpi_radi"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>

<td align="left">
<span class="label_it">- Time:</span>
</td>

<td align="right">
<input type="text" name="c_hpi_time"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>

<tr>
<td align="left">
<span class="label_it">- Positives:</span>
</td>

<td align="right">
<input type="text" name="c_hpi_pos"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>

<td align="left">
<span class="label_it">- Negatives:</span>
</td>

<td align="right">
<input type="text" name="c_hpi_neg"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>
</table>
</fieldset>

<fieldset>
<table width="100%" border="0">
<tr>
<td align="right">
&nbsp;&nbsp;&nbsp;&nbsp;
<span class="label_it">MEDICATIONS:</span>
</td>
<td align="right">
<input type="text" name="c_hpi_med"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>
</table>
</fieldset>

<fieldset>
<table width="100%" border="0">
<tr>
<td align="right">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="label_it">ALLERGIES:</span>
</td>
<td align="right">
<input type="text" name="c_hpi_aller"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>
</table>
</fieldset>

<fieldset>
<table width="100%" border="0">
<tr>
<td align="right">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="label_it">PMHx:</span>
</td>
<td align="right">
<input type="text" name="c_hpi_pmhx"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>
</table>
</fieldset>

<fieldset>
<table width="100%" border="0">
<tr>
<td align="right">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="label_it">FHx:</span>
</td>
<td align="right">
<input type="text" name="c_hpi_fhx"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>
</table>
</fieldset>

<fieldset>
<table width="100%" border="0">
<tr>
<td align="right">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="label_it">SHx:</span>
</td>
<td align="right">
<input type="text" name="c_hpi_shx"  style="height:18px;font-size:0.8em;padding:2px;padding-top:0px;width:755px" maxlength="150">
</td>
</tr>
</table>
</fieldset>

<fieldset>
<table width="100%" border="0">
<tr>
<td align="left">
<span class='short_explanation'>ros:</span>
</td>
<td>
<span class="dynamic_it">(<span style="color: red;"> Positives</span>)&nbsp;&nbsp;&nbsp;(<strike>Negatives</strike>)&nbsp;&nbsp;&nbsp;(<span style="color:gray;">Status Undetermined</span>)</span>
</td>
</tr>
</table>

<hr color="#000">

<table width=100% border="1">
<tr>

<td bgcolor="#C0C0C0">
<select name='c_ros_gene' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="X">X</option>
</select>
</td>
<td bgcolor="#C0C0C0">
<span class="ros_it">general</span>
</td>

<td bgcolor="#C0C0C0">
<select name='c_ros_resp' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="X">X</option>
</select>
</td>
<td bgcolor="#C0C0C0">
<span class="ros_it">respiratory</span>
</td>

<td bgcolor="#C0C0C0">
<select name='c_ros_geni' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="X">X</option>
</select>
</td>
<td bgcolor="#C0C0C0">
<span class="ros_it">genitourinary</span>
</td>

<td bgcolor="#C0C0C0">
<select name='c_ros_neur' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="X">X</option>
</select>
</td>
<td bgcolor="#C0C0C0">
<span class="ros_it">neurologic</span>
</td>
</tr>
<!-- -->

<tr>
<td>
<select name='c_ros_gene_ill' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="P">P</option>
<option Value="N">N</option>
<option Value="U">U</option>
</select>
</td>
<td>
<span class="ros_itnl">ill</span>
</td>

<td>
<select name='c_ros_resp_dys' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="P">P</option>
<option Value="N">N</option>
<option Value="U">U</option>
</select>
</td>
<td>
<span class="ros_itnl">dyspnea</span>
</td>

<td>
<select name='c_ros_geni_freq' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="P">P</option>
<option Value="N">N</option>
<option Value="U">U</option>
</select>
</td>
<td>
<span class="ros_itnl">frequency</span>
</td>

<td>
<select name='c_ros_neur_head' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="P">P</option>
<option Value="N">N</option>
<option Value="U">U</option>
</select>
</td>
<td>
<span class="ros_itnl">headache</span>
</td>

</tr>
<tr>
<td>
<select name='c_ros_gene_pall' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="P">P</option>
<option Value="N">N</option>
<option Value="U">U</option>
</select>
</td>
<td>
<span class="ros_itnl">pallor</span>
</td>

<td>
<select name='c_ros_resp_coug' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="P">P</option>
<option Value="N">N</option>
<option Value="U">U</option>
</select>
</td>
<td>
<span class="ros_itnl">cough</span>
</td>

<td>
<select name='c_ros_geni_urge' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="P">P</option>
<option Value="N">N</option>
<option Value="U">U</option>
</select>
</td>
<td>
<span class="ros_itnl">urgency</span>
</td>

<td>
<select name='c_ros_neur_spee' size="1" style="height:20px;font-size:0.8em;padding:0px;">
<option Value=""></option>
<option Value="P">P</option>
<option Value="N">N</option>
<option Value="U">U</option>
</select>
</td>
<td>
<span class="ros_itnl">speech change</span>
</td>
</tr>

</table>
</fieldset>

<br />
Program still broken - only partially displayed at this time...
<!--div class='container'>
<input type='submit' name='Submit' value='Submit' />
</div-->

</form>
</center>

<script type='text/javascript'>
/* <![CDATA[
*/
    var frmvalidator  = new Validator("BuildCase");
    frmvalidator.EnableOnPageErrorDisplay();
    frmvalidator.EnableMsgsTogether();
<?php phpRunLog("vo_cases_mstr.php - line:165\
"); ?>    
    frmvalidator.addValidation("c_patname","req","Please provide the PatientName");
// ]]>
</script>

</body>
</html>


<?PHP
/*
    Registration/Login script from HTML Form Guide
    V1.0

    This program is free software published under the
    terms of the GNU Lesser General Public License.
    http://www.gnu.org/copyleft/lesser.html
    

This program is distributed in the hope that it will
be useful - WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

For updates, please visit:
http://www.html-form-guide.com/php-form/php-registration-form.html
http://www.html-form-guide.com/php-form/php-login-form.html

*/
require_once("class.phpmailer.php");
require_once("formvalidator.php");

class FGMembersite
{
    var $admin_email;
    var $from_address;
    
    var $username;
    var $pwd;
    var $database;
    var $tablename;
    var $connection;
    var $rand_key;
    
    var $error_message;
    
    //-----Initialization -------
    function FGMembersite()
    {
        $this->sitename = 'lowkeysystems.com';
        $this->rand_key = '0iQx5oBk66oVZep';
    }
    
    function InitDB($host,$uname,$pwd,$database,$tablename)
    {
        $this->db_host  = $host;
        $this->username = $uname;
        $this->pwd  = $pwd;
        $this->database  = $database;
        $this->tablename = $tablename;
        
    }
    function SetAdminEmail($email)
    {
        $this->admin_email = $email;
    }
    
    function SetWebsiteName($sitename)
    {
        $this->sitename = $sitename;
    }
    
    function SetRandomKey($key)
    {
        $this->rand_key = $key;
    }
    
    //-------Main Operations ----------------------
    function RegisterUser()
    {
        if(!isset($_POST['submitted']))
        {
           return false;
        }
        
        $formvars = array();
        
        if(!$this->ValidateRegistrationSubmission())
        {
            return false;
        }
        
        $this->CollectRegistrationSubmission($formvars);
        
        if(!$this->SaveToDatabase($formvars))
        {
            return false;
        }
        
        if(!$this->SendUserConfirmationEmail($formvars))
        {
            return false;
        }

        $this->SendAdminIntimationEmail($formvars);
        
        return true;
    }
    
// *********    
    function ReSendPassword()
    {
        if(!isset($_POST['submitted']))
        {
           return false;
        }
        
        $formvars = array();
        
        if(!$this->ValidateReSendSubmission())
        {
            return false;
        }
        
        $this->CollectResendSubmission($formvars);
        
        if(!$this->SendReSendEmail($formvars))
        {
            return false;
        }
        
        return true;
    }
// *********
    
    function ConfirmUser()
    {
        if(empty($_GET['code'])||strlen($_GET['code'])<=10)
        {
            $this->HandleError("Please provide the confirm code");
            return false;
        }
        $user_rec = array();
        if(!$this->UpdateDBRecForConfirmation($user_rec))
        {
            return false;
        }
        
        $this->SendUserWelcomeEmail($user_rec);
        
        $this->SendAdminIntimationOnRegComplete($user_rec);
        
        return true;
    }    
    
    function Login()
    {
        if(empty($_POST['username']))
        {
            $this->HandleError("UserName is empty!");
            return false;
        }
        
        if(empty($_POST['password']))
        {
            $this->HandleError("Password is empty!");
            return false;
        }
        
        $username = trim($_POST['username']);
        $password = trim($_POST['password']);
        
        if(!isset($_SESSION)){ session_start(); }
        if(!$this->CheckLoginInDB($username,$password))
        {
            return false;
        }
        
        $_SESSION[$this->GetLoginSessionVar()] = $username;
        
        return true;
    }
    
    function CheckLogin()
    {
         if(!isset($_SESSION)){ session_start(); }

         $sessionvar = $this->GetLoginSessionVar();
         
         if(empty($_SESSION[$sessionvar]))
         {
            return false;
         }
         return true;
    }
    
    function UserFullName()
    {
        return isset($_SESSION['name_of_user'])?$_SESSION['name_of_user']:'';
    }
    
    function UserEmail()
    {
        return isset($_SESSION['email_of_user'])?$_SESSION['email_of_user']:'';
    }
    
    function LogOut()
    {
        session_start();
        
        $sessionvar = $this->GetLoginSessionVar();
        
        $_SESSION[$sessionvar]=NULL;
        
        unset($_SESSION[$sessionvar]);
    }
    
    function EmailResetPasswordLink()
    {
        if(empty($_POST['email']))
        {
            $this->HandleError("Email is empty!");
            return false;
        }
        $user_rec = array();
        if(false === $this->GetUserFromEmail($_POST['email'], $user_rec))
        {
            return false;
        }
        if(false === $this->SendResetPasswordLink($user_rec))
        {
            return false;
        }
        return true;
    }
    
    function ResetPassword()
    {
        if(empty($_GET['email']))
        {
            $this->HandleError("Email is empty!");
            return false;
        }
        if(empty($_GET['code']))
        {
            $this->HandleError("reset code is empty!");
            return false;
        }
        $email = trim($_GET['email']);
        $code = trim($_GET['code']);
        
        if($this->GetResetPasswordCode($email) != $code)
        {
            $this->HandleError("Bad reset code!");
            return false;
        }
        
        $user_rec = array();
        if(!$this->GetUserFromEmail($email,$user_rec))
        {
            return false;
        }
        
        $new_password = $this->ResetUserPasswordInDB($user_rec);
        if(false === $new_password || empty($new_password))
        {
            $this->HandleError("Error updating new password");
            return false;
        }
        
        if(false == $this->SendNewPassword($user_rec,$new_password))
        {
            $this->HandleError("Error sending new password");
            return false;
        }
        return true;
    }
    
    function ChangePassword()
    {
        if(!$this->CheckLogin())
        {
            $this->HandleError("Not logged in!");
            return false;
        }
        
        if(empty($_POST['oldpwd']))
        {
            $this->HandleError("Old password is empty!");
            return false;
        }
        if(empty($_POST['newpwd']))
        {
            $this->HandleError("New password is empty!");
            return false;
        }
        
        $user_rec = array();
        if(!$this->GetUserFromEmail($this->UserEmail(),$user_rec))
        {
            return false;
        }
        
        $pwd = trim($_POST['oldpwd']);
        
        if($user_rec['password'] != md5($pwd))
        {
            $this->HandleError("The old password does not match!");
            return false;
        }
        $newpwd = trim($_POST['newpwd']);
        
        if(!$this->ChangePasswordInDB($user_rec, $newpwd))
        {
            return false;
        }
        return true;
    }
    
    //-------Public Helper functions -------------
    function GetSelfScript()
    {
        return htmlentities($_SERVER['PHP_SELF']);
    }    
    
    function SafeDisplay($value_name)
    {
        if(empty($_POST[$value_name]))
        {
            return'';
        }
        return htmlentities($_POST[$value_name]);
    }
    
    function RedirectToURL($url)
    {
    // If no headers are sent, send one
    if (!headers_sent())
    {
        // echo $url + " " + $_SESSION['hold_username'];
        /* if ($url = "vot_cases.php" & !$_SESSION['hold_username'] = "admin")
        {
            // $url = "vot_cases_na.php";
        } */
            header("Location: $url");
            exit;
        // }
    }
    /* else
    {
    // echo "Redirection error has occurred!";
    exit;
    } */
    }
            
    function GetSpamTrapInputName()
    {
        return 'sp'.md5('KHGdnbvsgst'.$this->rand_key);
    }
    
    function GetErrorMessage()
    {
        if(empty($this->error_message))
        {
            return '';
        }
        $errormsg = nl2br(htmlentities($this->error_message));
        return $errormsg;
    }    
    //-------Private Helper functions-----------
    
    function HandleError($err)
    {
        $this->error_message .= $err."\\r\
";
    }
    
    function HandleDBError($err) 
    {
        $this->HandleError($err."\\r\
 mysqlerror:".mysql_error());
    }
    
    function GetFromAddress()
    {
        if(!empty($this->from_address))
        {
            return $this->from_address;
        }

        $host = $_SERVER['SERVER_NAME'];
        $from ="$host";
        return $from;
    } 
    
    function GetLoginSessionVar()
    {
        $retvar = md5($this->rand_key);
        $retvar = 'usr_'.substr($retvar,0,10);
        return $retvar;
    }
    
    function CheckLoginInDB($username,$password)
    {
        if(!$this->DBLogin())
        {
            $this->HandleError("Database login failed!");
            return false;
        }          
        $username = $this->SanitizeForSQL($username);
        $pwdmd5 = md5($password);
        // $qry = "Select name, email from $this->tablename where username='$username' and password='$pwdmd5' and confirmcode='y'";
        $qry = "Select name, email from $this->tablename where username='$username' and passwrd='$password' and confirmcode='y'";
        
        $result = mysql_query($qry,$this->connection);
        
        if(!$result || mysql_num_rows($result) <= 0)
        {
            $this->HandleError("Error logging in. The username or password does not match");
            return false;
        }
        
        $row = mysql_fetch_assoc($result);
        
        $_SESSION['hold_id_user']  = $row['id_user'];
        $_SESSION['hold_username']  = $row['username'];
        $_SESSION['name_of_user']  = $row['name'];
        $_SESSION['email_of_user'] = $row['email'];
        
        return true;
    }
    
    function UpdateDBRecForConfirmation(&$user_rec)
    {
        if(!$this->DBLogin())
        {
            $this->HandleError("Database login failed!");
            return false;
        }   
        $confirmcode = $this->SanitizeForSQL($_GET['code']);
        
        $result = mysql_query("Select name, email from $this->tablename where confirmcode='$confirmcode'",$this->connection);   
        if(!$result || mysql_num_rows($result) <= 0)
        {
            $this->HandleError("Wrong confirm code.");
            return false;
        }
        $row = mysql_fetch_assoc($result);
        $user_rec['name'] = $row['name'];
        $user_rec['email']= $row['email'];
        
        $qry = "Update $this->tablename Set confirmcode='y' Where  confirmcode='$confirmcode'";
        
        if(!mysql_query( $qry ,$this->connection))
        {
            $this->HandleDBError("Error inserting data to the table\
query:$qry");
            return false;
        }      
        return true;
    }
    
    function ResetUserPasswordInDB($user_rec)
    {
        $new_password = substr(md5(uniqid()),0,10);
        
        if(false == $this->ChangePasswordInDB($user_rec,$new_password))
        {
            return false;
        }
        return $new_password;
    }
    
    function ChangePasswordInDB($user_rec, $newpwd)
    {
        $newpwd = $this->SanitizeForSQL($newpwd);
        
        $qry = "Update $this->tablename Set password='".md5($newpwd)."' Where  id_user=".$user_rec['id_user']."";
        
        if(!mysql_query( $qry ,$this->connection))
        {
            $this->HandleDBError("Error updating the password \
query:$qry");
            return false;
        }     
        return true;
    }
    
    function GetUserFromEmail($email,&$user_rec)
    {
        if(!$this->DBLogin())
        {
            $this->HandleError("Database login failed!");
            return false;
        }   
        $email = $this->SanitizeForSQL($email);
        
        $result = mysql_query("Select * from $this->tablename where email='$email'",$this->connection);  

        if(!$result || mysql_num_rows($result) <= 0)
        {
            $this->HandleError("There is no user with email: $email");
            return false;
        }
        $user_rec = mysql_fetch_assoc($result);

        
        return true;
    }
    
    function SendUserWelcomeEmail(&$user_rec)
    {
        $mailer = new PHPMailer();
        
        $mailer->CharSet = 'utf-8';
        
        $mailer->AddAddress($user_rec['email'],$user_rec['name']);
        
        $mailer->Subject = "Welcome to ".$this->sitename;

        $mailer->From = $this->admin_email;
        // $mailer->From = $this->GetFromAddress();
        
        $mailer->Body ="Hello ".$user_rec['name']."\\r\
\\r\
".
        "Welcome! Your registration with ".$this->sitename." is now complete.\\r\
".
        "\\r\
".
        "Regards,\\r\
".
        "WebMaster\\r\
".
        $this->sitename;

        if(!$mailer->Send())
        {
            $this->HandleError("Failed sending user welcome email.");
            return false;
        }
        return true;
    }
    
    function SendAdminIntimationOnRegComplete(&$user_rec)
    {
        if(empty($this->admin_email))
        {
            return false;
        }
        $mailer = new PHPMailer();
        
        $mailer->CharSet = 'utf-8';
        
        $mailer->AddAddress($this->admin_email);
        
        $mailer->Subject = "Registration Completed: ".$user_rec['name'];

        $mailer->From = $this->admin_email;         
        // $mailer->From = $this->GetFromAddress();
        
        $mailer->Body ="A new user registered at ".$this->sitename."\\r\
".
        "UserName: ".$user_rec['username']."\\r\
".
        "PWD: ".$user_rec['passwrd']."\\r\
".
        "Name: ".$user_rec['name']."\\r\
".
        "Email address: ".$user_rec['email']."\\r\
".
        "Phone Number: ".$user_rec['phone_number'];
        "Registration: ".$user_rec['regdate'];
        
        if(!$mailer->Send())
        {
            return false;
        }
        return true;
    }
    
    function GetResetPasswordCode($email)
    {
       return substr(md5($email.$this->sitename.$this->rand_key),0,10);
    }
    
    function SendResetPasswordLink($user_rec)
    {
        $email = $user_rec['email'];
        
        $mailer = new PHPMailer();
        
        $mailer->CharSet = 'utf-8';
        
        $mailer->AddAddress($email,$user_rec['name']);
        
        $mailer->Subject = "Your reset password request at ".$this->sitename;

        $mailer->From = $this->admin_email;
        // $mailer->From = $this->GetFromAddress();
        
        $link = $this->GetAbsoluteURLFolder().
                '/resetpwd.php?email='.
                urlencode($email).'&code='.
                urlencode($this->GetResetPasswordCode($email));

        $mailer->Body ="Hello ".$user_rec['name']."\\r\
\\r\
".
        "There was a request to reset your password at ".$this->sitename."\\r\
".
        "This is your assigned Password: \\r\
".$user_rec['passwrd']."\\r\
".
        "Regards,\\r\
".
        "WebMaster\\r\
".
        $this->sitename;
        
        if(!$mailer->Send())
        {
            return false;
        }
        return true;
    }
    
    function SendNewPassword($user_rec, $new_password)
    {
        $email = $user_rec['email'];
        
        $mailer = new PHPMailer();
        
        $mailer->CharSet = 'utf-8';
        
        $mailer->AddAddress($email,$user_rec['name']);
        
        $mailer->Subject = "Your new password for ".$this->sitename;

        $mailer->From = $this->admin_email;
        // $mailer->From = $this->GetFromAddress();
        
        $mailer->Body ="Hello ".$user_rec['name']."\\r\
\\r\
".
        "Your password was reset successfully. ".
        "Here is your current login:\\r\
".
        "Username:".$user_rec['username']."\\r\
".
        "PWD:".$user_rec['passwrd']."\\r\
".
        "\\r\
".
        /* "Login here: ".$this->GetAbsoluteURLFolder()."/login.php\\r\
".
        "\\r\
". */
        "Regards,\\r\
".
        "WebMaster\\r\
".
        $this->sitename;
        
        if(!$mailer->Send())
        {
            return false;
        }
        return true;
    }    
    
    function ValidateRegistrationSubmission()
    {
        //This is a hidden input field. Humans won't fill this field.
        if(!empty($_POST[$this->GetSpamTrapInputName()]) )
        {
            //The proper error is not given intentionally
            $this->HandleError("Automated submission prevention: case 2 failed");
            return false;
        }
        
        $validator = new FormValidator();
        $validator->addValidation("username","req","Please fill in UserName");
        $validator->addValidation("name","req","Please fill in Name");
        $validator->addValidation("phone_number","req","Please fill in Phone Number");
        $validator->addValidation("email","email","The input for Email should be a valid email value");
        $validator->addValidation("email","req","Please fill in Email");
        // $validator->addValidation("password","req","Please fill in Password");

        
        if(!$validator->ValidateForm())
        {
            $error='';
            $error_hash = $validator->GetErrors();
            foreach($error_hash as $inpname => $inp_err)
            {
                $error .= $inpname.':'.$inp_err."\
";
            }
            $this->HandleError($error);
            return false;
        }        
        return true;
    }
    
    function CollectRegistrationSubmission(&$formvars)
    {
        $formvars['username'] = $this->Sanitize($_POST['username']);
        $formvars['name'] = $this->Sanitize($_POST['name']);
        $formvars['email'] = $this->Sanitize($_POST['email']);
        $formvars['phone_number'] = $this->Sanitize($_POST['phone_number']);
        $formvars['password'] = $this->Sanitize($_POST['password']);
        $formvars['passwrd'] = $this->Sanitize($_POST['passwrd']);
        $formvars['regdate'] = $this->Sanitize($_POST['regdate']);
    }
    
    function SendUserConfirmationEmail(&$formvars)
    {
        $mailer = new PHPMailer();
        
        $mailer->CharSet = 'utf-8';
        
        $mailer->AddAddress($formvars['email'],$formvars['name']);
        
        $mailer->Subject = "Your registration with ".$this->sitename;

        $mailer->From = $this->admin_email;
        // $mailer->From = $this->GetFromAddress();        
        
        $confirmcode = $formvars['confirmcode'];
        
        $confirm_url = $this->GetAbsoluteURLFolder().'/confirmreg.php?code='.$confirmcode;
        
        $mailer->Body ="Hello ".$formvars['name']."\\r\
\\r\
".
        "Thanks for your registration with ".$this->sitename."\\r\
\\r\
".
        "Here is your assigned login:\\r\
".
        "Username: ".$formvars['username']."\\r\
".
        "PWD: ".$formvars['passwrd']."\\r\
\\r\
".
        "With this information provided:\\r\
".
        "Name: ".$formvars['name']."\\r\
".
        "Email: ".$formvars['email']."\\r\
".
        "Phone Number: ".$formvars['phone_number']."\\r\
".
        // "Please click the link below to confirm your registration.\\r\
".
        // "$confirm_url\\r\
".
        "\\r\
".
        "Regards,\\r\
".
        "WebMaster\\r\
".
        $this->sitename;

        if(!$mailer->Send())
        {
            $this->HandleError("Failed sending registration confirmation email.");
            return false;
        }
        return true;
    }
    function GetAbsoluteURLFolder()
    {
        $scriptFolder = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) ? 'https://' : 'http://';
        $scriptFolder .= $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
        return $scriptFolder;
    }
    
    function SendAdminIntimationEmail(&$formvars)
    {
        if(empty($this->admin_email))
        {
            return false;
        }
        $mailer = new PHPMailer();
        
        $mailer->CharSet = 'utf-8';
        
        $mailer->AddAddress($this->admin_email);
        
        $mailer->Subject = "New registration: ".$formvars['name'];

        $mailer->From = $this->admin_email;
        // $mailer->From = $this->GetFromAddress(); 
        
        $mailer->Body ="A new user registered at ".$this->sitename."\\r\
\\r\
".
        "UserName: ".$formvars['username']."\\r\
".
        "PWD: ".$formvars['passwrd']."\\r\
\\r\
".
        "Name: ".$formvars['name']."\\r\
".
        "Email address: ".$formvars['email']."\\r\
".
        "Phone Number: ".$formvars['phone_number']."\\r\
".
        "Registration: ".$formvars['regdate'];
        
        if(!$mailer->Send())
        {
            return false;
        }
        return true;
    }

// *********
    function ValidateReSendSubmission()
    {
    // echo "ValidateReSendSubmission\\r\
";
        //This is a hidden input field. Humans won't fill this field.
        if(!empty($_POST[$this->GetSpamTrapInputName()]) )
        {
            //The proper error is not given intentionally
            $this->HandleError("Automated submission prevention: case 2 failed");
            return false;
        }
        
        $validator = new FormValidator();
        $validator->addValidation("username","req","Please fill in UserName");
        
            if(!$validator->ValidateForm())
        {
        // echo "line 764\\r\
";
            $error='';
            $error_hash = $validator->GetErrors();
            foreach($error_hash as $inpname => $inp_err)
            {
                $error .= $inpname.':'.$inp_err."\
";
            }
            $this->HandleError($error);
            return false;
            
        // ******    
        if(!$this->DBLogin())
        {
            $this->HandleError("Database login failed!");
            return false;
        }
        if(!$this->Ensuretable())
        {
            return false;
        }
        
        echo "line 785\\r\
";
        
        $username = $_POST['username'];
        // $username = $this->SanitizeForSQL($username);
        
        $qry = "Select * from $this->tablename where username='$username'";
        
        $result = mysql_query($qry,$this->connection);
        
        if(!$result || mysql_num_rows($result) <= 0)
        {
            $this->HandleError("line-792 Error selection. The UserName was not found");
            return false;
        }
        
        echo "line 800\\r\
";
        
        $row = mysql_fetch_assoc($result);
        
        }       
        return true;
    }
    
    function CollectReSendSubmission(&$formvars)
    {
        $formvars['id_user'] = id_user;
        $formvars['username'] = $this->Sanitize($_POST['username']);
        $formvars['name'] = name;
        $formvars['email'] = email;
        $formvars['passwrd'] = passwrd;
    }
    
    function SendReSendEmail(&$formvars)
    {
        $mailer = new PHPMailer();
        
        $mailer->CharSet = 'utf-8';
        
     $mailer->AddAddress($formvars['email'],$formvars['name']);
        
        $mailer->Subject = "ReSend of Password from ".$this->sitename;

        // $mailer->From = $this->admin_email;
        $mailer->From = $this->GetFromAddress();        
        
        $mailer->Body ="Hello ".$formvars['name']."\\r\
\\r\
".
        "Here is your system assigned LogIn:\\r\
".
        "Username: ".$formvars['username']."\\r\
".
        "Password: ".$formvars['passwrd']."\\r\
\\r\
".
        
        "id_user: ".$formvars['id_user']."\\r\
\\r\
".
        
        "\\r\
".
        "Regards,\\r\
".
        "WebMaster\\r\
".
        $this->sitename;

        if(!$mailer->Send())
        {
            $this->HandleError("Failed resending Password email.");
            return false;
        }
        return true;
    }
// *********
   
    function SaveToDatabase(&$formvars)
    {
        if(!$this->DBLogin())
        {
            $this->HandleError("Database login failed!");
            return false;
        }
        if(!$this->Ensuretable())
        {
            return false;
        }
        if(!$this->IsFieldUnique($formvars,'username'))
        {
            $this->HandleError("This UserName is already used. Please try another username");
            return false;
        }
        if(!$this->IsFieldUnique($formvars,'name'))
        {
            $this->HandleError("This Name is already used. Please try another name");
            return false;
        }        
        if(!$this->IsFieldUnique($formvars,'email'))
        {
            $this->HandleError("This email is already registered");
            return false;
        }
        if(!$this->InsertIntoDB($formvars))
        {
            $this->HandleError("Inserting to Database failed!");
            return false;
        }
        return true;
    }
    
    function IsFieldUnique($formvars,$fieldname)
    {
        $field_val = $this->SanitizeForSQL($formvars[$fieldname]);
        $qry = "select username from $this->tablename where $fieldname='".$field_val."'";
        $result = mysql_query($qry,$this->connection);   
        if($result && mysql_num_rows($result) > 0)
        {
            return false;
        }
        return true;
    }
    
    function DBLogin()
    {

        $this->connection = mysql_connect($this->db_host,$this->username,$this->pwd);

        if(!$this->connection)
        {   
            $this->HandleDBError("Database Login failed! Please make sure that the DB login credentials provided are correct");
            return false;
        }
        if(!mysql_select_db($this->database, $this->connection))
        {
            $this->HandleDBError('Failed to select database: '.$this->database.' Please make sure that the database name provided is correct');
            return false;
        }
        if(!mysql_query("SET NAMES 'UTF8'",$this->connection))
        {
            $this->HandleDBError('Error setting utf8 encoding');
            return false;
        }
        return true;
    }    
    
    function Ensuretable()
    {
        $result = mysql_query("SHOW COLUMNS FROM $this->tablename");   
        if(!$result || mysql_num_rows($result) <= 0)
        {
            return $this->CreateTable();
        }
        return true;
    }
    
    function CreateTable()
    {
        $qry = "Create Table $this->tablename (".
                "id_user INT NOT NULL AUTO_INCREMENT ,".
                "username VARCHAR( 16 ) NOT NULL ,".
                "name VARCHAR( 128 ) NOT NULL ,".
                "email VARCHAR( 64 ) NOT NULL ,".
                "phone_number VARCHAR( 16 ) NOT NULL ,".
                "password VARCHAR( 32 ) NOT NULL ,".
                "confirmcode VARCHAR(32) ,".
                "passwrd VARCHAR( 32 ) ,".
                "regdate DATETIME ,".
                "PRIMARY KEY ( id_user )".
                ")";
                
        if(!mysql_query($qry,$this->connection))
        {
            $this->HandleDBError("Error creating the table \
query was\
 $qry");
            return false;
        }
        return true;
    }
    
    function InsertIntoDB(&$formvars)
    {
    
        $confirmcode = $this->MakeConfirmationMd5($formvars['email']);
        
        $confirmcode = "y";
        $formvars['confirmcode'] = $confirmcode;
        
        $Formvars['passwrd'] = $passwrd;
        $Formvars['regdate'] = $regdate;
        
        $insert_query = 'insert into '.$this->tablename.'(
                username,
                name,
                email,
                phone_number,
                password,
                confirmcode,
                passwrd,
                regdate
                )
                values
                (
                "' . $this->SanitizeForSQL($formvars['username']) . '",
                "' . $this->SanitizeForSQL($formvars['name']) . '",
                "' . $this->SanitizeForSQL($formvars['email']) . '",
                "' . $this->SanitizeForSQL($formvars['phone_number']) . '",
                "' . md5($formvars['password']) . '",
                "' . $confirmcode . '",
                "' . $this->SanitizeForSQL($formvars['passwrd']) . '",
                "' . $this->SanitizeForSQL($formvars['regdate']) . '"
                )';      
        if(!mysql_query( $insert_query ,$this->connection))
        {
            $this->HandleDBError("Error inserting data to the table\
query:$insert_query");
            return false;
        }        
        return true;
    }
    function MakeConfirmationMd5($email)
    {
        $randno1 = rand();
        $randno2 = rand();
        return md5($email.$this->rand_key.$randno1.''.$randno2);
    }
    function SanitizeForSQL($str)
    {
        if( function_exists( "mysql_real_escape_string" ) )
        {
              $ret_str = mysql_real_escape_string( $str );
        }
        else
        {
              $ret_str = addslashes( $str );
        }
        return $ret_str;
    }
    
 /*
    Sanitize() function removes any potential threat from the
    data submitted. Prevents email injections or any other hacker attempts.
    if $remove_nl is true, newline chracters are removed from the input.
    */
    function Sanitize($str,$remove_nl=true)
    {
        $str = $this->StripSlashes($str);

        if($remove_nl)
        {
            $injections = array('/(\
+)/i',
                '/(\\r+)/i',
                '/(\	+)/i',
                '/(%0A+)/i',
                '/(%0D+)/i',
                '/(%08+)/i',
                '/(%09+)/i'
                );
            $str = preg_replace($injections,'',$str);
        }

        return $str;
    }    
    function StripSlashes($str)
    {
        if(get_magic_quotes_gpc())
        {
            $str = stripslashes($str);
        }
        return $str;
    }    
}
?>


<?PHP
/*
  -------------------------------------------------------------------------
      PHP Form Validator (formvalidator.php)
              Version 1.1
    This program is free software published under the
    terms of the GNU Lesser General Public License.

    This program is distributed in the hope that it will
    be useful - WITHOUT ANY WARRANTY; without even the
    implied warranty of MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE.
        
    For updates, please visit:
    http://www.html-form-guide.com/php-form/php-form-validation.html
    
    Questions & comments please send to info@html-form-guide.com
  -------------------------------------------------------------------------  
*/

/**
* Carries information about each of the form validations
*/
class ValidatorObj
{
    var $variable_name;
    var $validator_string;
    var $error_string;
}

/**
* Base class for custom validation objects
**/
class CustomValidator 
{
    function DoValidate(&$formars,&$error_hash)
    {
        return true;
    }
}

/** Default error messages*/
define("E_VAL_REQUIRED_VALUE","Please enter the value for %s");
define("E_VAL_MAXLEN_EXCEEDED","Maximum length exceeded for %s.");
define("E_VAL_MINLEN_CHECK_FAILED","Please enter input with length more than %d for %s");
define("E_VAL_ALNUM_CHECK_FAILED","Please provide an alpha-numeric input for %s");
define("E_VAL_ALNUM_S_CHECK_FAILED","Please provide an alpha-numeric input for %s");
define("E_VAL_NUM_CHECK_FAILED","Please provide numeric input for %s");
define("E_VAL_ALPHA_CHECK_FAILED","Please provide alphabetic input for %s");
define("E_VAL_ALPHA_S_CHECK_FAILED","Please provide alphabetic input for %s");
define("E_VAL_EMAIL_CHECK_FAILED","Please provide a valida email address");
define("E_VAL_LESSTHAN_CHECK_FAILED","Enter a value less than %f for %s");
define("E_VAL_GREATERTHAN_CHECK_FAILED","Enter a value greater than %f for %s");
define("E_VAL_REGEXP_CHECK_FAILED","Please provide a valid input for %s");
define("E_VAL_DONTSEL_CHECK_FAILED","Wrong option selected for %s");
define("E_VAL_SELMIN_CHECK_FAILED","Please select minimum %d options for %s");
define("E_VAL_SELONE_CHECK_FAILED","Please select an option for %s");
define("E_VAL_EQELMNT_CHECK_FAILED","Value of %s should be same as that of %s");
define("E_VAL_NEELMNT_CHECK_FAILED","Value of %s should not be same as that of %s");



/**
* FormValidator: The main class that does all the form validations
**/
class FormValidator 
{
    var $validator_array;
    var $error_hash;
    var $custom_validators;
    
    function FormValidator()
    {
        $this->validator_array = array();
        $this->error_hash = array();
        $this->custom_validators=array();
    }
    
    function AddCustomValidator(&$customv)
    {
    // echo "line 81:\\r\
";
        array_push($this->custom_validators,$customv);
    }

    function addValidation($variable,$validator,$error)
    {
    // echo "line 87:\\r\
";
        $validator_obj = new ValidatorObj();
        $validator_obj->variable_name = $variable;
        $validator_obj->validator_string = $validator;
        $validator_obj->error_string = $error;
        array_push($this->validator_array,$validator_obj);
    }
    function GetErrors()
    {
        return $this->error_hash;
    }

    function ValidateForm()
    {
    // echo "line 101:\\r\
";
        $bret = true;

        $error_string="";
        $error_to_display = "";

        
        if(strcmp($_SERVER['REQUEST_METHOD'],'POST')==0)
        {
        // echo "line 110:\\r\
";
            $form_variables = $_POST;
        }
        else
        {
        // echo "line 115:\\r\
";
            $form_variables = $_GET;
        }

        $vcount = count($this->validator_array);
        

        foreach($this->validator_array as $val_obj)
        {
            if(!$this->ValidateObject($val_obj,$form_variables,$error_string))
            {
                $bret = false;
                $this->error_hash[$val_obj->variable_name] = $error_string;
            }
        }

        if(true == $bret && count($this->custom_validators) > 0)
        {
            foreach( $this->custom_validators as $custom_val)
            {
                if(false == $custom_val->DoValidate($form_variables,$this->error_hash))
                {
                    $bret = false;
                }
            }
        }
        return $bret;
    }


    function ValidateObject($validatorobj,$formvariables,&$error_string)
    {
    // echo "line 147:\\r\
";
        $bret = true;

        $splitted = explode("=",$validatorobj->validator_string);
        $command = $splitted[0];
        $command_value = '';

        if(isset($splitted[1]) && strlen($splitted[1])>0)
        {
            $command_value = $splitted[1];
        }

        $default_error_message="";
        
        $input_value ="";

        if(isset($formvariables[$validatorobj->variable_name]))
        {
         $input_value = $formvariables[$validatorobj->variable_name];
        }

        $bret = $this->ValidateCommand($command,$command_value,$input_value,
                                    $default_error_message,
                                    $validatorobj->variable_name,
                                    $formvariables);
        // echo "line 172:\\r\
";
        
        if(false == $bret)
        {
            if(isset($validatorobj->error_string) &&
                strlen($validatorobj->error_string)>0)
            {
                $error_string = $validatorobj->error_string;
            }
            else
            {
                $error_string = $default_error_message;
            }

        }//if
        return $bret;
    }
        
    function validate_req($input_value, &$default_error_message,$variable_name)
    {
    // echo "line 192:\\r\
";
      $bret = true;
          if(!isset($input_value) ||
            strlen($input_value) <=0)
        {
            $bret=false;
            $default_error_message = sprintf(E_VAL_REQUIRED_VALUE,$variable_name);
        }    
      return $bret;    
    }

    function validate_maxlen($input_value,$max_len,$variable_name,&$default_error_message)
    {
        $bret = true;
        if(isset($input_value) )
        {
            $input_length = strlen($input_value);
            if($input_length > $max_len)
            {
                $bret=false;
                $default_error_message = sprintf(E_VAL_MAXLEN_EXCEEDED,$variable_name);
            }
        }
        return $bret;
    }

    function validate_minlen($input_value,$min_len,$variable_name,&$default_error_message)
    {
        $bret = true;
        if(isset($input_value) )
        {
            $input_length = strlen($input_value);
            if($input_length < $min_len)
            {
                $bret=false;
                $default_error_message = sprintf(E_VAL_MINLEN_CHECK_FAILED,$min_len,$variable_name);
            }
        }
        return $bret;
    }

    function test_datatype($input_value,$reg_exp)
    {
        if(ereg($reg_exp,$input_value))
        {
            return false;
        }
        return true;
    }

    function validate_email($email) 
    {
        return preg_match("/^[_\\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\\.)+[a-zA-Z]{2,6}$/i", $email);
    }

    function validate_for_numeric_input($input_value,&$validation_success)
    {
        
        $more_validations=true;
        $validation_success = true;
        if(strlen($input_value)>0)
        {
            
            if(false == is_numeric($input_value))
            {
                $validation_success = false;
                $more_validations=false;
            }
        }
        else
        {
            $more_validations=false;
        }
        return $more_validations;
    }

    function validate_lessthan($command_value,$input_value,
                $variable_name,&$default_error_message)
    {
        $bret = true;
        if(false == $this->validate_for_numeric_input($input_value,
                                    $bret))
        {
            return $bret;
        }
        if($bret)
        {
            $lessthan = doubleval($command_value);
            $float_inputval = doubleval($input_value);
            if($float_inputval >= $lessthan)
            {
                $default_error_message = sprintf(E_VAL_LESSTHAN_CHECK_FAILED,
                                        $lessthan,
                                        $variable_name);
                $bret = false;
            }//if
        }
        return $bret ;
    }

    function validate_greaterthan($command_value,$input_value,$variable_name,&$default_error_message)
    {
        $bret = true;
        if(false == $this->validate_for_numeric_input($input_value,$bret))
        {
            return $bret;
        }
        if($bret)
        {
            $greaterthan = doubleval($command_value);
            $float_inputval = doubleval($input_value);
            if($float_inputval <= $greaterthan)
            {
                $default_error_message = sprintf(E_VAL_GREATERTHAN_CHECK_FAILED,
                                        $greaterthan,
                                        $variable_name);
                $bret = false;
            }//if
        }
        return $bret ;
    }

    function validate_select($input_value,$command_value,&$default_error_message,$variable_name)
    {
        $bret=false;
        if(is_array($input_value))
        {
            foreach($input_value as $value)
            {
                if($value == $command_value)
                {
                    $bret=true;
                    break;
                }
            }
        }
        else
        {
            if($command_value == $input_value)
            {
                $bret=true;
            }
        }
        if(false == $bret)
        {
            $default_error_message = sprintf(E_VAL_SHOULD_SEL_CHECK_FAILED,
                                            $command_value,$variable_name);
        }
        return $bret;
    }

    function validate_dontselect($input_value,$command_value,&$default_error_message,$variable_name)
    {
       $bret=true;
        if(is_array($input_value))
        {
            foreach($input_value as $value)
            {
                if($value == $command_value)
                {
                    $bret=false;
                    $default_error_message = sprintf(E_VAL_DONTSEL_CHECK_FAILED,$variable_name);
                    break;
                }
            }
        }
        else
        {
            if($command_value == $input_value)
            {
                $bret=false;
                $default_error_message = sprintf(E_VAL_DONTSEL_CHECK_FAILED,$variable_name);
            }
        }
      return $bret;
    }



    function ValidateCommand($command,$command_value,$input_value,&$default_error_message,$variable_name,$formvariables)
    {
        $bret=true;
        switch($command)
        {
            case 'req':
                        {
                            $bret = $this->validate_req($input_value, $default_error_message,$variable_name);
                            break;
                        }

            case 'maxlen':
                        {
                            $max_len = intval($command_value);
                            $bret = $this->validate_maxlen($input_value,$max_len,$variable_name,
                                                $default_error_message);
                            break;
                        }

            case 'minlen':
                        {
                            $min_len = intval($command_value);
                            $bret = $this->validate_minlen($input_value,$min_len,$variable_name,
                                            $default_error_message);
                            break;
                        }

            case 'alnum':
                        {
                            $bret= $this->test_datatype($input_value,"[^A-Za-z0-9]");
                            if(false == $bret)
                            {
                                $default_error_message = sprintf(E_VAL_ALNUM_CHECK_FAILED,$variable_name);
                            }
                            break;
                        }

            case 'alnum_s':
                        {
                            $bret= $this->test_datatype($input_value,"[^A-Za-z0-9 ]");
                            if(false == $bret)
                            {
                                $default_error_message = sprintf(E_VAL_ALNUM_S_CHECK_FAILED,$variable_name);
                            }
                            break;
                        }

            case 'num':
            case 'numeric':
                        {
                            $bret= $this->test_datatype($input_value,"[^0-9]");
                            if(false == $bret)
                            {
                                $default_error_message = sprintf(E_VAL_NUM_CHECK_FAILED,$variable_name);
                            }
                            break;                            
                        }

            case 'alpha':
                        {
                            $bret= $this->test_datatype($input_value,"[^A-Za-z]");
                            if(false == $bret)
                            {
                                $default_error_message = sprintf(E_VAL_ALPHA_CHECK_FAILED,$variable_name);
                            }
                            break;
                        }
            case 'alpha_s':
                        {
                            $bret= $this->test_datatype($input_value,"[^A-Za-z ]");
                            if(false == $bret)
                            {
                                $default_error_message = sprintf(E_VAL_ALPHA_S_CHECK_FAILED,$variable_name);
                            }
                            break;
                        }
            case 'email':
                        {
                            if(isset($input_value) && strlen($input_value)>0)
                            {
                                $bret= $this->validate_email($input_value);
                                if(false == $bret)
                                {
                                    $default_error_message = E_VAL_EMAIL_CHECK_FAILED;
                                }
                            }
                            break;
                        }
            case "lt": 
            case "lessthan": 
                        {
                            $bret = $this->validate_lessthan($command_value,
                                                    $input_value,
                                                    $variable_name,
                                                    $default_error_message);
                            break;
                        }
            case "gt": 
            case "greaterthan": 
                        {
                            $bret = $this->validate_greaterthan($command_value,
                                                    $input_value,
                                                    $variable_name,
                                                    $default_error_message);
                            break;
                        }

            case "regexp":
                        {
                            if(isset($input_value) && strlen($input_value)>0)
                            {
                                if(!preg_match("$command_value",$input_value))
                                {
                                    $bret=false;
                                    $default_error_message = sprintf(E_VAL_REGEXP_CHECK_FAILED,$variable_name);
                                }
                            }
                            break;
                        }
          case "dontselect": 
          case "dontselectchk":
          case "dontselectradio":
                        {
                            $bret = $this->validate_dontselect($input_value,
                                                               $command_value,
                                                               $default_error_message,
                                                                $variable_name);
                             break;
                        }//case

          case "shouldselchk":
          case "selectradio":
                      {
                            $bret = $this->validate_select($input_value,
                                   $command_value,
                                   $default_error_message,
                                    $variable_name);
                            break;
                      }//case
          case "selmin":
                        {
                            $min_count = intval($command_value);

                            if(isset($input_value))
                            {
                                if($min_count > 1)
                                {
                                    $bret = (count($input_value) >= $min_count )?true:false;
                                }
                                else
                                {
                                  $bret = true;
                                }
                            }
                            else
                            {
                                $bret= false;
                                $default_error_message = sprintf(E_VAL_SELMIN_CHECK_FAILED,$min_count,$variable_name);
                            }

                            break;
                        }//case
         case "selone":
                        {
                            if(false == isset($input_value)||
                                strlen($input_value)<=0)
                            {
                                $bret= false;
                                $default_error_message = sprintf(E_VAL_SELONE_CHECK_FAILED,$variable_name);
                            }
                            break;
                        }
         case "eqelmnt":
                        {

                            if(isset($formvariables[$command_value]) &&
                               strcmp($input_value,$formvariables[$command_value])==0 )
                            {
                                $bret=true;
                            }
                            else
                            {
                                $bret= false;
                                $default_error_message = sprintf(E_VAL_EQELMNT_CHECK_FAILED,$variable_name,$command_value);
                            }
                        break;
                        }
          case "neelmnt":
                        {
                            if(isset($formvariables[$command_value]) &&
                               strcmp($input_value,$formvariables[$command_value]) !=0 )
                            {
                                $bret=true;
                            }
                            else
                            {
                                $bret= false;
                                $default_error_message = sprintf(E_VAL_NEELMNT_CHECK_FAILED,$variable_name,$command_value);
                            }
                            break;
                        }
         
        }//switch
        return $bret;
    }//validdate command


}

?>

The first program vo_cases_mstr.php uses the server code found in the second program vo_membersite.php this is where I believe that the problem is. I have also included the validator program as well, but there are no required fields that need to be checked at this time.

I have only written the program to create the casetable and then insert a partial record of fields. I checked and saw that now post fields were being populated and I need to get the first record written to the casetable then I will put in the code to update the records as they are available.

I hope this helps, thank you so much, Jerry

Please be aware that the mysql_* extension is now deprecated as of the current version of PHP and will very likely be removed from the next 5.x version and will likely not be in PHP 6.x (when it eventually is released). You should migrate over to either the mysqli_* extension or to PDO. PDO is a better choice as it doesn’t tie you down so much to a particular database server software.

Once you have migrated you should use Prepared Statements to prevent SQL Injection attacks. Have a read of this article from the PHP manual, it shows how to use prepared statements with PDO and also explains the principle.