HI i am new for Chronoform and php ia m using joomla 1.5.22 and Chrono form v3
I have created a form which can direct to different forms according to the selection populated from database
What i am trying to do is is to check one of the record (which will be sumbited and cary on on the other forms with session) if it exists in the database and there are 2 fields (field_a) and (field_b) are empty (value is 0 or null)
after user input the card no in the field - it will show validation message
next to the form field = accepted
or error = not valid or already registered etc
This can be done once the user submit so the form comes back to the form until valid or to selection url
Form Html
Form JavaScript:
I belive i need to amend the details here , to add a cross reference validation
On Submit code
Help Required
I have created a form which can direct to different forms according to the selection populated from database
What i am trying to do is is to check one of the record (which will be sumbited and cary on on the other forms with session) if it exists in the database and there are 2 fields (field_a) and (field_b) are empty (value is 0 or null)
after user input the card no in the field - it will show validation message
next to the form field = accepted
or error = not valid or already registered etc
This can be done once the user submit so the form comes back to the form until valid or to selection url
Form Html
<div class="form_item">
<div class="form_element cf_heading">
<h1 class="cf_text">Card Registration Form</h1>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_heading">
<h2 class="cf_text">Register a New Frii Card & Create a New Account</h2>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 300px;">*Please enter the last 8 digits of the long card number on the front of the card </label>
<input class="cf_inputbox required validate-number" maxlength="25" size="30" title="This Card number may have already been registered or is incorrect, Please check and try again." id="text_2" name="FrmCardNo" type="text" />
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_text"> <span class="cf_text">This is the number printer on the back of the card you are registering.</span> </div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 300px;">*Confirm your Frii Card Type </label>
<select class="cf_inputbox validate-selection" id="select_5" size="1" title="your Frii Card Type " name="FrmCardType">
<option value="">Select Option</option>
<?php
do {
?>
<option value="<?php echo $row_rsCardType['Product']?>"><?php echo $row_rsCardType['Product']?></option>
<?php
} while ($row_rsCardType = mysql_fetch_assoc($rsCardType));
$rows = mysql_num_rows($rsCardType);
if($rows > 0) {
mysql_data_seek($rsCardType, 0);
$row_rsCardType = mysql_fetch_assoc($rsCardType);
}
?>
</select>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_text"> <span class="cf_text">The card type is written onthe back of your Frii Card</span> </div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 300px;">Enter Your Mobile Number</label>
<input class="cf_inputbox required validate-number" maxlength="11" size="30" title="Mobile Number" id="text_6" name="FrmMobileNo" type="text" />
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_text"> <span class="cf_text">This number will be used to secure your rewards, text you balance updates when you swipe and redemptions when you qualify. This may be the only way to link you to your Frii card so please notify us if you lose or change your number.</span> </div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 300px;">Please provide an email address : </label>
<input class="cf_inputbox validate-email" maxlength="150" size="30" title="mail address : " id="text_8" name="FrmEmail" type="text" />
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_text"> <span class="cf_text">This is not compulsory but will help to identify you if you lose your card, login details or phone.</span> </div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_button">
<input value="Go to Next Step" name="button_11" type="submit" />
</div>
<div class="cfclear"> </div>
</div>
<input value="New_Card" id="hidden_13" name="SubmType" type="hidden" />
Form JavaScript:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_testform = "localhost";
$database_testform = "friiwo_1";
$username_testform = "root";
$password_testform = "";
$testform = mysql_pconnect($hostname_testform, $username_testform, $password_testform) or trigger_error(mysql_error(),E_USER_ERROR);
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_testform, $testform);
$query_rsCardType = "SELECT DISTINCT Product FROM accounts";
$rsCardType = mysql_query($query_rsCardType, $testform) or die(mysql_error());
$row_rsCardType = mysql_fetch_assoc($rsCardType);
$totalRows_rsCardType = mysql_num_rows($rsCardType);
$colname_Recordset1 = "-1";
if (isset($_GET['CardNo'])) {
$colname_Recordset1 = $_GET['CardNo'];
}
mysql_select_db($database_testform, $testform);
$query_Recordset1 = sprintf("SELECT Username, CardNo, Editable FROM accounts WHERE CardNo = %s" , GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $testform) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
I belive i need to amend the details here , to add a cross reference validation
On Submit code
<?php
//let's start the session
session_start();
//now lets register our session variables
session_register('FrmCardNo');
session_register('FrmMobileNo');
session_register('FrmEmail');
session_register('SubmType');
session_register('FrmCardType');
//finally, let's store our posted valuses in the variables
$_SESSION['FrmCardNo'] = $_POST['FrmCardNo'];
$_SESSION['FrmMobileNo'] = $_POST['FrmMobileNo'];
$_SESSION['FrmEmail'] = $_POST['FrmEmail'];
$_SESSION['SubmType'] = $_POST['SubmType'];
$_SESSION['FrmCardType'] = $_POST['FrmCardType'];
?>
<?php $source = JRequest::getString('FrmCardType', '', 'post');
echo gettype($source);
switch ($source) {
case 'Experience':
$url = 'FriiExperience';
break;
case 'Mobile':
$url = 'FriiMobileCard';
break;
case 'Frii-Music':
$url = 'FriiMusic';
break;
case 'Giving':
$url = 'FriiGiving';
break;
case 'Holiday':
$url = 'FriiHoliday';
break;
}
$url = 'index.php?option=com_chronocontact&chronoformname='.$url;
$mainframe->redirect($url);
?>
Help Required