Page 1 of 1

Data Insertion in database ----Problem being Faced

Posted: Wed Jul 02, 2008 4:52 am
by dumlee
I am able to enter all data being asked from the user in a form to the database but not able to Enter Username and password.


<?php
require_once(BL_PATH."/HTMLControls.php");
?>
<form method="post" onSubmit="return submitForm(this)">
<input type="hidden" name="signup">

<table border="0" align="center" cellpadding="0" cellspacing="0">

<tr>
<td class="border_rht_lft"></td>
</tr>

<tr>

<td class="content_bg_style" style="padding-top:60px" valign="top">
<table width="991" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="text_14_2"><div style="width:86%; margin-left:auto; margin-right:auto"><strong>Registration - First Time User</strong></div></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>

<tr>
<td colspan="3" align="right">
<?php
$errorMessage = $sessionManager->getSessionVariable("ErrorMessage");
if(isset($errorMessage) && (is_array($errorMessage)) && (count($errorMessage) > 0)){
echo UtilityManager::generateErrorBlock($errorMessage);
$sessionManager->setSessionVariable("ErrorMessage",NULL);
}else{
$successMessage = $sessionManager->getSessionVariable("SuccessMessage");
if(isset($successMessage) && (is_array($successMessage)) && (count($successMessage) > 0)){
echo UtilityManager::generateSuccessBlock($successMessage);
$sessionManager->setSessionVariable("SuccessMessage",NULL);
}
}
?>
</td>
</tr>

<tr>
<td valign="top">
<table width="86%" border="0" cellspacing="0" cellpadding="0" align="center">

<tr>
<td width="11" valign="top"><img src="<?php echo IMG_PATH;?>/round_lineleft.gif" alt="" width="11" height="10" /></td>
<td width="828" class="round_linel"></td>
<td width="11" valign="top"><img src="<?php echo IMG_PATH;?>/round_lineright.gif" alt="" width="11" height="10" /></td>
</tr>
<tr>
<td valign="top" class="round_linelside">&nbsp;</td>
<td valign="top" class="round_bg_line">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="text_14_2 dotted"><strong>Basic Information of User</strong></td>
</tr>
<tr height="20px">
<td class="note">Fields Mark with (*) are Mandatory.</td>
</tr>
<tr >
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3">
<table width="50%" border="0" align="center" cellspacing="0" cellpadding="5">
<tr>

</tr>

</tr>

<tr>
<td>User Name <br>(For Future Login) <span class="red_txt"> *</span></td>
<td align="left" width="260">
<div align="left">
<input class="textfld" type="text" name="username" id="username" value="<?php echo $userProfile->getUserName()?>" maxlength="32"></div></td>
</tr>



<tr>
<td>First Name <span class="red_txt"> *</span></td>
<td align="left" width="260">
<div align="left">
<input class="textfld" type="text" name="name" id="name" value="<?php echo $userProfile->getName()?>" maxlength="32"></div></td>
</tr>

<tr>
<td>Middle Name </td>
<td align="left" width="260">
<div align="left">
<input class="textfld" type="text" name="middlename" id="middlename" value="<?php echo $userProfile->getMiddleName()?>" maxlength="32"></div></td>
</tr>

<tr>
<td>Last Name <span class="red_txt"> *</span></td>
<td align="left" width="260">
<div align="left">
<input class="textfld" type="text" name="lastname" id="lastname" value="<?php echo $userProfile->getLastName()?>" maxlength="32"></div></td>
</tr>


<tr>
<td>Password <span class="red_txt"> *</span></td>
<td align="left" width="260">
<div align="left">
<input class="textfld" type="password" name="password" id="password" value="<?php echo $userProfile->getPassword()?>" maxlength="32"></div></td>
</tr>

<tr>
<td width="38%" align="left">Confirm password <span class="red_txt"> *</span></td>
<td align="left"><input class="textfld" type="password" name="confirmpassword" id="confirmpassword" value="" maxlength="32"/>
</td>
</tr>

<tr>
<td>Gender <span class="red_txt"> *</span></td>
<?php
if($userProfile->getGender() == "M" || $userProfile->getGender() == ""){
$genderM = "checked";
}else{
$genderF = "checked";
}
?>

<td><input name="gender" type="radio" <?php echo $genderM ;?> value="M" > Male<input name="gender" type="radio" <?php echo $genderF ;?> value="F" > Female</td>
</tr>

<tr>
<td>Business Name </td>
<td align="left" width="260">
<input class="textfld" type="text" name="businesstitle" id="businesstitle" value="<?php echo $userProfile->getBusinessTitle()?>" maxlength="128"></td>
</tr>

<tr>

</tr>

<tr>
<td>Address <span class="red_txt"> *</span></td>
<td>
<input class="textfld" type="address" name="address" id="address" value="<?php echo $userProfile->getAddress()?>" maxlength="64"></td>
</tr>

<tr>
<td>Address 2</td>
<td>
<input class="textfld" type="address2" name="address2" id="address2" value="<?php echo $userProfile->getAddress2()?>" maxlength="64"></td>
</tr>

<tr>
<td>City <span class="red_txt"> *</span></td>
<td align="left" width="260">
<input class="textfld" type="text" name="city" id="city" value="<?php echo $userProfile->getCity()?>" maxlength="64"></td>
</tr>

<tr id="usZipCodeDiv">
<td>Zip Code <span class="red_txt"> *</span>&nbsp;&nbsp;</td>
<td>
<input class="textfld3" type="text" name="usZipCode" id="usZipCode" maxlength="5" value="<?php echo $userProfile->getPostalCode()?>" ></td>
</tr>

<tr id="caPostalCodeDiv">
<td>Postal Code <span class="red_txt"> *</span>&nbsp;&nbsp;</td>
<td>
<input class="textfld5" type="text" name="caPostalcode" id="caPostalcode" maxlength="8" value="<?php echo $userProfile->getPostalCode()?>" ></td>
</tr>


<tr>
<td>Mobile Number</td>
<td align="left" width="260">
<input class="textfld" type="text" name="mobile" id="mobile" value="<?php echo $userProfile->getMobile()?>" maxlength="15"></td>
</tr>

</table>
</td>
</tr>

<tr>
<td style="background-color:#FFFFFF;">
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color:#FFFFFF;">
<tr >
<td>&nbsp;</td>
</tr>

<tr>
<td class="text_14_2 dotted"><strong>Information required for Authentication purposes</strong></td>
</tr>

</table>
</td>
</tr>

<tr >
<td style="background-color:#FFFFFF;">&nbsp;</td>
<tr>
<tr>
<td style="background-color:#FFFFFF;">
<table width="68%" align="center" border="0" cellspacing="0" cellpadding="5" style="background-color:#FFFFFF;">
<tr>
<td width="38%" align="left">Email Address <span class="red_txt"> *</span></td>
<td align="left"><input class="textfld" type="text" name="email" id="email" value="<?php echo $userProfile->getEmail()?>" maxlength="32"/>
</td>
</tr>
<tr>
<td width="38%" align="left">Confirm Email Address <span class="red_txt"> *</span></td>
<td align="left"><input class="textfld" type="text" name="confirmEmail" id="confirmEmail" value="" maxlength="32"/>
</td>
</tr>
<tr>
<td nowrap align="left">National Provider Identifier (NPI#) <span class="red_txt"> *</span></td>
<td align="left" width="260">
<input class="textfld5" type="text" name="NPI" id="NPI" value="<?php echo $user->getNPI()?>" maxlength="<?php echo NPI_MAX_LENGTH ?>"></td>
</tr>

<tr id="MDTitle" class="collapseRow">
<td valign="top">MD specialty <span class="red_txt"> *</span>&nbsp;&nbsp;</td>
<td align="left" width="260">
<?php /*
<select name="MDspecialty[]" multiple='multiple' size="5">
<?php
echo HTMLControls::getMDSpecialtyControl( explode(',',$userProfile->getMDSpecialty()));?>
</select>
*/?>

</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="background-color:#FFFFFF;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr >
<td style="background-color:#FFFFFF;">&nbsp;</td>
</tr>
<tr>
<td class="text_14_2 dotted"><strong>For Security Purposes</strong></td>
</tr>
</table>
</td>
</tr>
<tr >
<td style="background-color:#FFFFFF;">&nbsp;</td>
</tr>

<tr>
<td style="background-color:#FFFFFF;">
<table width="40%" align="center" border="0" cellspacing="0" cellpadding="5">
<tr>
<td align="center" colspan="2"><img src="<?php echo IMG_PATH?>/captchaImage.php"><br><span class="note">Enter the letters as they are shown in the image above</span><br><br>
<input class="textfld6" name="verificationCode" type="text" id="verificationCode"/><br>
</td>
</tr>
<tr >
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2" align="center"> <input class="textfld" type="hidden" value="1" name="actSave" /><input class="add_to_bg" type="submit" value="Submit" name="submit"/></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td class="round_linerights"></td>
</tr>
<tr>
<td valign="top"><img src="<?php echo IMG_PATH;?>/round_lineleftbottom.gif" alt="" width="11" height="11" /></td>
<td class="round_linelbottom"></td>
<td valign="top"><img src="<?php echo IMG_PATH;?>/round_linerightbottom.gif" alt="" width="11" height="11" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</form>


=========================================================================

<?php
//echo "Hello";
global $FE;
$FE = "../";
require_once($FE."/Library/common.inc.php");
require_once(BL_PATH . "/UtilityManager.inc.php");
require_once(BL_PATH .'/Users/Registeration/init.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $pageTitle ;?></title>
<link href="<?php print HTTP_PATH; ?>/CSS/adminCss.css.php" rel="stylesheet" type="text/css" media="all">
<link href="<?php print HTTP_PATH; ?>/CSS/checkList.css" rel="stylesheet" type="text/css" media="all">
<?php
print UtilityManager::includeJS('functions.js');
print UtilityManager::includeJS('checkList.js');
print UtilityManager::includeJS('winjs/dobRegistration.js');
?>

<script language="javascript">
/*
function winAlert(msg,onf){
alert(msg);
document.getElementById(onf).focus();
}*/


function submitForm(){
return true;
username = document.getElementById('username');
name = document.getElementById('name');
middlename = document.getElementById('middlename');
lastname = document.getElementById('lastname');
email = document.getElementById('email');
gender = document.getElementById('gender');
businesstitle = document.getElementById('businesstitle');
city = document.getElementById('city');
country = document.getElementById('country');
postalcode = document.getElementById('postalcode');
address = document.getElementById('address');
phone = document.getElementById('phone');
mobile = document.getElementById('mobile');
fax = document.getElementById('fax');
pwd = document.getElementById('password');
confirmpassword = document.getElementById('confirmpassword');
NPI = document.getElementById('NPI');
aterms = document.getElementById('acceptTerms');
verificationCode = document.getElementById('verificationCode');

if(isEmpty(name.value)){
winAlert("Please enter User Name ",'username');
return false;
}else{
unsetAlertStyle('username')
}

if(isEmpty(name.value)){
winAlert("Please enter firstname",'name');
return false;
}else{
unsetAlertStyle('name')
}

if(isEmpty(middlename.value)){
winAlert("Please enter middlename",'middlename');
return false;
}else{
unsetAlertStyle('middlename')
}

if(isEmpty(lastname.value)){
winAlert("Please enter lastname",'lastname');
return false;
}else{
unsetAlertStyle('lastname')
}

if(isEmpty(age.value)){
winAlert("Please enter age",'age');
return false;
}else{
unsetAlertStyle('age')
}

if(isEmpty(businesstitle.value)){
winAlert("Please enter business title",'businesstitle');
return false;
}else{
unsetAlertStyle('businesstitle')
}

if(isEmpty(country.value)){
winAlert("Please select country",'country');
return false;
}else{
unsetAlertStyle('country')
}

if(isEmpty(city.value)){
winAlert("Please enter city",'city');
return false;
}else{
unsetAlertStyle('city')
}

if(isEmpty(postalcode.value)){
winAlert("Please enter postalcode",'postalcode');
return false;
}else{
unsetAlertStyle('postalcode')
}

if(!isNumeric(postalcode.value)){
winAlert("Please enter valid postalcode",'postalcode');
return false;
}else{
unsetAlertStyle('postalcode')
}

if(isEmpty(address.value)){
winAlert("Please enter address",'address');
return false;
}else{
unsetAlertStyle('address')
}

if(isEmpty(phone.value)){
winAlert("Please enter phone number",'phone');
return false;
}else{
unsetAlertStyle('phone')
}

if(isEmpty(mobile.value)){
winAlert("Please enter mobile",'mobile');
return false;
}else{
unsetAlertStyle('mobile')
}

if(isEmpty(fax.value)){
winAlert("Please enter fax number",'fax');
return false;
}else{
unsetAlertStyle('fax')
}

if(isEmpty(email.value)){
winAlert("Please enter email address",'email');

return false;
}else{
unsetAlertStyle('email')
}


if(isEmpty(pwd.value)){
winAlert("Please enter password",'password');
return false;
}else{
unsetAlertStyle('password')
}

if(pwd.value.length < 6){
winAlert("Password length must be greater than or equal to 6 characters",'password');
return false;
}else{
unsetAlertStyle('password')
}

if(isEmpty(confirmpassword.value)){
winAlert("Please enter confirm password",'confirmpassword');
return false;
}else{
unsetAlertStyle('confirmpassword')
}

if(trim(pwd.value) != trim(confirmpassword.value)){
cpwd.value='';
winAlert("Two passwords passed does not match",'confirmpassword');
return false;
}else{
unsetAlertStyle('confirmpassword')
}

if(isEmpty(NPI.value)){
winAlert("Please enter NPI",'NPI');
return false;
}else{
unsetAlertStyle('NPI')
}

if(isEmpty(verificationCode.value)){
winAlert("Please enter verfication code from image",'verificationCode');
return false;
}else{
unsetAlertStyle('verificationCode')
}

if(!aterms.checked){
winAlert("Please check the Accept Terms",'acceptTerms');
return false;
}else{
unsetAlertStyle('acceptTerms')
}

return true;
}

// show/hide "otherTitle" div
function ShowOtherTitle(id){
var el = document.getElementById("otherTitle");
if(el){
if(id == "Other"){
el.className = "expandRow";
}else{
el.className = "collapseRow";
}
}else{
alert("no id found with title 'otherTitle' ");
}
}

// show/hide "showState" div
function ShowState(id){
var el = document.getElementById("showState");
if(el){
if(id == "US"){
el.className = "expandRow";
}else{
el.className = "collapseRow";
}
}else{
alert("no id found with title 'showState' ");
}
}

// show/hide "showRegion" div
function ShowRegion(id){
var el = document.getElementById("showRegion");
if(el){
if(id == "CA"){
el.className = "expandRow";
}else{
el.className = "collapseRow";
}
}else{
alert("no id found with title 'showRegion' ");
}
}

// show/hide "showUSGMT" div
function ShowUSGMT(id){
var el = document.getElementById("showUSGMT");
if(el){
if(id == "US"){
el.className = "expandRow";
}else{
el.className = "collapseRow";
}
}
}

// show/hide "showCAGMT" div
function ShowCAGMT(id){
var el = document.getElementById("showCAGMT");
if(el){
if(id == "CA"){
el.className = "expandRow";
}else{
el.className = "collapseRow";
}
}
}

// show/hide "MDspecialty" div
function ShowMDSpecialty(id){
var el = document.getElementById("MDTitle");
if(el){
if(id == "MD"){
el.className = "expandRow";
}else{
el.className = "collapseRow";
}
}else{
alert("no id found with title 'MDspecialty' ");
}
}

// show/hide Zip code/Postal code
function ShowDiv(value){
if(value == "US"){
document.getElementById("usZipCodeDiv").className = "expandRow";
document.getElementById("caPostalCodeDiv").className = "collapseRow";
return;
}
if(value == "CA"){
document.getElementById("usZipCodeDiv").className = "collapseRow";
document.getElementById("caPostalCodeDiv").className = "expandRow";
return;
}
document.getElementById("usZipCodeDiv").className = "expandRow";
document.getElementById("caPostalCodeDiv").className = "collapseRow";
}

function onLoad(){
//var title = document.getElementById('title')[document.getElementById('title').selectedIndex].value;

if(title == 'Other'){
ShowOtherTitle('Other');
}


}
</script>
</head>
<body onLoad="onLoad()">
<?php
require_once(TEMPLATES_PATH."/Users/header.php");
require_once(TEMPLATES_PATH . "/Users/Register/register.php");
require_once(TEMPLATES_PATH."/Users/internalFooter.php");
require_once(TEMPLATES_PATH."/Users/homeFooter.php");


?>
</body>
</html>
=============================================================================

<?php

//define('USER_SECTION',DOCTOR_REGISTER);
//define('USER_TYPE',USER_TYPE_DOCTOR);
ob_start();
define('USER_SECTION',USER_REGISTER); // For General User
define('USER_TYPE',USER_TYPE_GENERAL); // For General User

require_once(BL_PATH .'/UtilityManager.inc.php');
require_once(BL_PATH .'/SessionManager.inc.php');
require_once(BL_PATH . '/HtmlValidations.inc.php');
$htmlValidations = new HtmlValidations();

if(UtilityManager::checkUserLoggedIn()){
REDIRECTBROWSER(UtilityManager::buildTargetURL('index.php', Array(),false));
}


$sessionManager = SessionManager::getInstance();

$errorMessage = "";

$pageTitle = "Register";

require_once(BL_PATH . '/User.inc.php');
$user = new User();
require_once(BL_PATH . '/UserProfile.inc.php');
$userProfile = new UserProfile();
require_once(BL_PATH . '/UserManager.inc.php');
$userManager = UserManager::getInstance();

// save a new/existing User
if (isset($REQUEST_DATA['actSave']) && $REQUEST_DATA['actSave'] == "1") {

// validation for first name
if(!UtilityManager::isEmpty($REQUEST_DATA['name'])){
if($htmlValidations->checkValidName($REQUEST_DATA['name'])){
$userProfile->setName($REQUEST_DATA['name']);
}else{
$message[] = "Enter valid first name.";
if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "name";
}
}
}else{
$message[] = "Enter your first name.";
if(!(isset($focus)) && ($focus == "")){
$focus = "name";
}
}


// validation for last name
if(!UtilityManager::isEmpty($REQUEST_DATA['lastname'])){
if($htmlValidations->checkValidName($REQUEST_DATA['lastname'])){
$userProfile->setLastName($REQUEST_DATA['lastname']);
}else{
$message[] = "Enter valid last name.";

if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "lastname";
}
}
}else{
$message[] = "Enter your last name .";
if(!(isset($focus)) && ($focus == "")){
$focus = "lastname";
}
}


// Validation For Confirm Password---

if(!UtilityManager::isEmpty($REQUEST_DATA['confirmpassword'])){
if($REQUEST_DATA['confirmpassword'] == $REQUEST_DATA['password']){
}else{
$message[] = 'Your entry in "Confirm Password field is invalid."';

if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "confirmpassword";
}
}
}else{//echo "confirmpassword";
$message[] = "Enter your confirm Password .";
if(!(isset($focus)) && ($focus == "")){
$focus = "confirmpassword";
}
}




// validation for Gender
if(($REQUEST_DATA['gender']) == ''){
$message[] = "Select your gender (Male/Female).";
if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "gender";
}
}else{
$userProfile->setGender($REQUEST_DATA['gender']);
}


// validation for business title
if(!UtilityManager::isEmpty($REQUEST_DATA['businesstitle'])){
if($htmlValidations->checkValidTitle($REQUEST_DATA['businesstitle'])){
$userProfile->setBusinessTitle($REQUEST_DATA['businesstitle']);
}else{
$message[] = "Enter valid business title.";

if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "businesstitle";
}
}
}

// validation for country
if(!UtilityManager::isEmpty($REQUEST_DATA['country'])){
$userProfile->setCountry($REQUEST_DATA['country']);
}else{
$message[] = "Enter your country name .";
if(!(isset($focus)) && ($focus == "")){
$focus = "country";
}
}

// validation for address
if(!UtilityManager::isEmpty($REQUEST_DATA['address'])){
if($htmlValidations->checkValidAddress($REQUEST_DATA['address'])){
}
$userProfile->setAddress($REQUEST_DATA['address']);
}else{
$message[] = "Enter your address.";
if(!(isset($focus)) && ($focus == "")){
$focus = "address";
}
}

// validation for address2
if(!UtilityManager::isEmpty($REQUEST_DATA['address2'])){
if($htmlValidations->checkValidAddress($REQUEST_DATA['address2'])){
}
$userProfile->setAddress2($REQUEST_DATA['address2']);
}

// validation for city
if(!UtilityManager::isEmpty($REQUEST_DATA['city'])){
if($htmlValidations->checkValidName($REQUEST_DATA['city'])){
$userProfile->setCity($REQUEST_DATA['city']);
}else{
$message[] = "Enter valid city name.";

if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "city";
}
}
}else{
$message[] = "Enter your city name .";
if(!(isset($focus)) && ($focus == "")){
$focus = "city";
}
}

// validation for state
if($REQUEST_DATA['country'] == "US"){
if(!UtilityManager::isEmpty($REQUEST_DATA['state'])){
$userProfile->setState($REQUEST_DATA['state']);
}else{
$message[] = "Enter your state name .";
if(!(isset($focus)) && ($focus == "")){
$focus = "state";
}
}
}

// validation for region
if($REQUEST_DATA['country'] == "CA"){
if(!UtilityManager::isEmpty($REQUEST_DATA['region'])){
$userProfile->setState($REQUEST_DATA['region']);
}else{
$message[] = "Enter your Prov/Terr.";
if(!(isset($focus)) && ($focus == "")){
$focus = "region";
}
}
}


// validation for postalcode
switch($REQUEST_DATA['country']){
Case "US":
if(!UtilityManager::isEmpty($REQUEST_DATA['usZipCode'])){
if($htmlValidations->checkZip($REQUEST_DATA['usZipCode'])){
$userProfile->setPostalCode($REQUEST_DATA['usZipCode']);
}else{
$message[] = $htmlValidations->strErrorMessage;
if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "usZipCode";
}
}
}else{
$message[] = "Enter your zip code.";
if(!(isset($focus)) && ($focus == "")){
$focus = "usZipCode";
}
}
break;
Case "CA":
if(!UtilityManager::isEmpty($REQUEST_DATA['caPostalcode'])){
if($htmlValidations->checkCanadaZip($REQUEST_DATA['caPostalcode'])){
$userProfile->setPostalCode($REQUEST_DATA['caPostalcode']);
}else{
$message[] = $htmlValidations->strErrorMessage;
if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "caPostalcode";
}
}
}else{
$message[] = "Enter your postal code.";
if(!(isset($focus)) && ($focus == "")){
$focus = "caPostalcode";
}
}
break;
Case "-1":
$message[] = "Enter your zip code.";
if(!(isset($focus)) && ($focus == "")){
$focus = "usZipCode";
}
break;
}

// validation for USGMT
if($REQUEST_DATA['country'] == "US"){
if(!UtilityManager::isEmpty($REQUEST_DATA['USGMT'])){
$userProfile->setGMT($REQUEST_DATA['USGMT']);
}else{
$message[] = "Enter your GMT.";
if(!(isset($focus)) && ($focus == "")){
$focus = "USGMT";
}
}
}

// validation for CAGMT
if($REQUEST_DATA['country'] == "CA"){
if(!UtilityManager::isEmpty($REQUEST_DATA['CAGMT']) ){
$userProfile->setGMT($REQUEST_DATA['CAGMT']);
}else{
$message[] = "Enter your GMT.";
if(!(isset($focus)) && ($focus == "")){
$focus = "CAGMT";
}
}
}


$phoneNumber = $REQUEST_DATA['phone']; //an array

// validation for mobile number
if(!UtilityManager::isEmpty($REQUEST_DATA['mobile'])){
if($htmlValidations->checkCustomMobile($REQUEST_DATA['mobile'])){
$userProfile->setMobile($REQUEST_DATA['mobile']);
}else{
$message[] = "Enter valid mobile number format.";

if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "mobile";
}
}
}
// validation for Email Address
if(!UtilityManager::isEmpty($REQUEST_DATA['email'])){
if($htmlValidations->validEmailId($REQUEST_DATA['email'])){
$user->setEmail($REQUEST_DATA['email']);
}else{
$message[] = "Enter valid email address.";

if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "email";
}
}
}else{
$message[] = "Enter your email address.";
if(!(isset($focus)) && ($focus == "")){
$focus = "email";
}
}

//validation if email already exists in database
if(!UtilityManager::isEmpty($REQUEST_DATA['email'])){
if($userManager->checkValidEmail($REQUEST_DATA['email'])){
$userProfile->setEmail($REQUEST_DATA['email']);
}else{
$message[] = "Given email address already exists.";

if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "email";
}
}
}

// validation for confirm email
if(!UtilityManager::isEmpty($REQUEST_DATA['confirmEmail'])){
if($REQUEST_DATA['confirmEmail'] == $REQUEST_DATA['email']){
}else{
$message[] = 'Your entry in "Confirm Email field is invalid."';

if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "confirmEmail";
}
}
}else{//echo "confirmpassword";
$message[] = "Enter your confirm email address.";
if(!(isset($focus)) && ($focus == "")){
$focus = "confirmEmail";
}
}





// validation for NPI
if(!UtilityManager::isEmpty($REQUEST_DATA['NPI'])){
if($htmlValidations->checkValidNPI($REQUEST_DATA['NPI'])){
$user->setNPI($REQUEST_DATA['NPI']);
}else{
$message[] = $htmlValidations->strErrorMessage;

if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "NPI";
}
}
}else{
$message[] = "Enter your NPI.";
if(!(isset($focus)) && ($focus == "")){
$focus = "NPI";
}
}

//validation if NPI already exists in database
if(!UtilityManager::isEmpty($REQUEST_DATA['NPI'])){
if($userManager->checkValidNPI($REQUEST_DATA['NPI'])){
$user->setNPI($REQUEST_DATA['NPI']);
}else{
$message[] = "The NPI number that you entered has already been registered with us. Please check the NPI number and try again. For further support contact us at <a href='mailto:support@medminister.com'>support@medminister.com</a>";

if(!(isset($focus)) && ($focus == "")){
//this will determine element ID where should be the focus after the page loads if needed
$focus = "NPI";
}
}
}


$userProfile->setFirstName($REQUEST_DATA['name']);
$userProfile->setMiddleName($REQUEST_DATA['middlename']);
$userProfile->setLastName($REQUEST_DATA['lastname']);

$userProfile->setPassword($REQUEST_DATA['password']);
$userProfile->setGender($REQUEST_DATA['gender']);
$userProfile->setBusinessTitle($REQUEST_DATA['businesstitle']);
$userProfile->setCountry($REQUEST_DATA['country']);
$userProfile->setCity($REQUEST_DATA['city']);
$userProfile->setAddress($REQUEST_DATA['address']);
$userProfile->setAddress2($REQUEST_DATA['address2']);
//$userProfile->setPhone(implode('',$phoneNumber));
$userProfile->setMobile($REQUEST_DATA['mobile']);
$userProfile->setEmail($REQUEST_DATA['email']);

$user->setUserName($REQUEST_DATA['userName']);



$user->setUserType(USER_TYPE_DOCTOR); //-----------> Need To be Changed

$user->setUserStatus(INACTIVE);
$user->setNPI($REQUEST_DATA['NPI']);
//pr($userProfile);
//check captcah first
$key = $sessionManager->getSessionValue('key');
$key = substr($key,0,5);

print_r ($user);
$number = $REQUEST_DATA['verificationCode'];
if($number!=$key){
$message[] = "Please enter verification code carefully.";
if(!(isset($focus)) && ($focus == "")){
$focus = "verificationCode";
}
}

if(count($message) > 0){
$sessionManager->setSessionVariable("ErrorMessage",$message);

}else{

$accountNumber = $userManager->getMaxAccNumber();
$user->setAccountNumber($accountNumber);
$id = $userManager->addUser($user);


//exit(0);
$message = "User saved successfully.";

// Setting last insert id from tblusers table for tblUserprofile table
if(($id != false) && ($id > 0)){
$userProfile->setUserId($id);
$sessionManager->setSessionVariable("lastRegistrationId", $id);
$userManager->addUserProfile($userProfile);
$emailAddresses[] = array(
'Email'=>$userProfile->getEmail(),
'FirstName' => $userProfile->getFirstName(),
'LastName' => $userProfile->getLastName(),
);
//$userManager->updateDoctorEmails($id,$emailAddresses);

}

if ($userManager->isError) {
$errorMessage = $userManager->getErrorMessage();
$message = "";
} else {
$user->setUserId($id);

//generate encoded string
$str = UtilityManager::generateEncodedString($userProfile->getFirstName(), $userProfile->getLastName(), $userProfile->getUserId());

// Sending email to New Created User
//$userManager->sendEmailToNewUser($user, $userProfile, $str);
if ($userManager->isError) {
$message .= " Email sending to user has been failed.";
}
// Sending email to Admin to give information of Newly Created User
//$userManager->sendEmailToAdminOfNewUser($user);

redirectBrowser(UtilityManager::buildTargetUrl('successfullyRegistered.php','array()',false));
}
}
}else{
//just show the form
}
?>

=======================================================




Pls Help

Re: Data Insertion in database ----Problem being Faced

Posted: Wed Jul 02, 2008 7:50 am
by Bill H
Too much code to read without it being in php tags and having indentation.

Re: Data Insertion in database ----Problem being Faced

Posted: Wed Jul 02, 2008 11:54 am
by Frozenlight777
I just became blind...