I am more than able to get ajax working, selecting countries, provinces, and cities FLAWLESSLY. My problem is that when I submit the form (and call it on itself) the AJAX values DISSAPPEAR in Firefox. However, they are still visible in IE6, IE7, IE8. I can't seem to find any error in my code, however, I have been working on this project now for several months already. Can anyone please help? I'm going nuts trying to figure this out.
<? include('includes/header.php'); ?>
<script type="text/javascript">
function querylocation(varStep){
var xmlHttp;
try{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e){
// Internet Explorer
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("Your browser does not support AJAX!");
return false;
}
}
}
if (varStep == 'country'){
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
document.getElementById('divprovince').innerHTML=xmlHttp.responseText;
}
};
country = document.getElementById('country').value;
xmlHttp.open("GET","querylocation.php?c=" + country,true);
xmlHttp.send(null);
}
if (varStep == 'province'){
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
document.getElementById('divcity').innerHTML=xmlHttp.responseText;
}
};
province = document.getElementById('province').value;
xmlHttp.open("GET","querylocation.php?p=" + province,true);
xmlHttp.send(null);
}
};
</script>
<?
$submit = $_REQUEST['submit'];
if ($submit){
// Get VARS
$screenname = $_REQUEST['screenname'];
$password = $_REQUEST['password'];
$repassword = $_REQUEST['repassword'];
$email = $_REQUEST['email'];
$reemail = $_REQUEST['reemail'];
$prefix = $_REQUEST['prefix'];
$firstname = $_REQUEST['firstname'];
$lastname = $_REQUEST['lastname'];
$suffix = $_REQUEST['suffix'];
$countryborn= $_REQUEST['countryBorn'];
$month = $_REQUEST['month'];
$day = $_REQUEST['day'];
$year = $_REQUEST['year'];
$gender = $_REQUEST['gender'];
$country = $_REQUEST['country'];
$province = $_REQUEST['province'];
$city = $_REQUEST['city'];
$truth = $_REQUEST['truth'];
$terms = $_REQUEST['terms'];
// Check VARS are ok to be inputted
// perform checks to make sure everything was filled out
$dserver = "-----------DELETED------------";
$dusername = "-----------DELETED------------";
$dpassword = "-----------DELETED------------";
$ddatabase = "-----------DELETED------------";
$mysql_access = mysql_connect($dserver, $dusername, $dpassword);
mysql_select_db($ddatabase) or die ('Cannot Select Database');
$query = "SELECT ScreenName FROM OfficeAdministration WHERE ScreenName='$screenname' LIMIT 1";
$result = mysql_query($query);
$nrows = mysql_num_rows($result);
if ($nrows > 0){
$notice = "Username is already in use<br>";
}
$query = "SELECT Email FROM OfficeAdministration WHERE Email='$email' LIMIT 1";
$result = mysql_query($query);
$erows = mysql_num_rows($result);
if ($erows > 0){
$notice = $notice . "Email is already registered to another user<br>";
}
if ($screenname == "") {
$notice = $notice . "Enter a screen name<br>";
}
if ($password == "") {
$notice = $notice . "Enter a password<br>";
}
if ($repassword == "") {
$notice = $notice . "Re-enter your password<br>";
}
if ($password != "" && $repassword != "" && ($password != $repassword)){
$notice = $notice . "Your passwords do not match, please try again<br>";
}
if ($email == "") {
$notice = $notice . "Enter an email<br>";
}
if ($reemail == "") {
$notice = $notice . "Re-enter your email<br>";
}
if ($email != "" && $reemail != "" && ($email != $reemail)){
$notice = $notice . "Your emails do not match, please try again<br>";
}
if ($firstname == "") {
$notice = $notice ."Enter a first name<br>";
}
if ($lastname == "") {
$notice = $notice . "Enter a last name<br>";
}
if ($month == " ") {
$notice = $notice . "Enter a birth month<br>";
}
if ($day == " ") {
$notice = $notice . "Enter a birth day<br>";
}
if ($year == " ") {
$notice = $notice . "Enter a birth year<br>";
}
if ($gender == " ") {
$notice = $notice . "Enter your gender<br>";
}
if ($country == "") {
$notice = $notice . "Enter the country you are in<br>";
}
if ($province == "") {
$notice = $notice . "Enter a Province, State, Region<br>";
}
if ($city == "") {
$notice = $notice . "Please enter a city<br>";
}
if ($truth == "") {
$notice = $notice . "You must agree to tell the truth or your account will be terminated<br>";
}
if ($terms == "") {
$notice = $notice . "You must agree to the terms if you wish to register an account.<br>";
}
if ($firstname != "" && $lastname != "" && $screenname != "" && $email != "" && $reemail != "" && $password != "" && $repassword != "" && $province != "" && $city != "" && $country != "" && $countryborn != "" && $month != " " && $day != " " && $year != " " && $gender != " " && $terms != "" && $truth != "" && ($password == $repassword) && ($email == $reemail) && ($nrows <= 0) && ($erows <= 0)){
// add to database as a deactivated account
$md5pass = md5($password);
$type = $account;
$dob = $month . " " . $day . ", " . $year;
$date = date('F j, Y - h:i:s a');
$request = "INSERT INTO OfficeAdministration VALUES(0, 0, '$email', '$md5pass', 0, '$prefix', '$firstname', '$lastname', '$suffix', '$screenname', '$countryborn', '$country', '$province', '$city', '$dob', 1, '$gender', 1, 'Member', 'Customer', '', '', '', '', '', '$date', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)";
$result = mysql_query($request);
$request = "INSERT INTO ForgotPassword VALUES('$email', '$md5pass', '$question', '$answer')";
$result = mysql_query($request);
// send verification email
$headers = "From: activation@-----------DELETED------------.ca\r\n"; // I suggest you try using only \n
$headers .= "Content-type: text/html; charset=iso-8859-9\r\n";
$headers .= "Reply-To: activation@-----------DELETED------------.ca\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSmail-Priority: High\r\n";
$message = '<table width="600" border="0" cellspacing="0" cellpadding="0">' .
' <tr>' .
' <td><p>Welcome to -----------DELETED------------.ca,</p>' .
' <p>Your account is just seconds away from being activated!<br />' .
' To complete your registration, you must click the link below; failure to do so will result in an "unverified account" and therefore will not be able to login.</p>' .
' <p>Activation link:<br />' .
' <a href="http://www.-----------DELETED------------.ca/activate.php?email=' . $email . '&code=' . $md5pass . '">http://www.ubeenshot.ca/activate.php?email=' . $email . '&code=' . $md5pass . '</a><br />' .
' </p>' .
' <p>Sincerely,<br />' .
' -----------DELETED------------ Administration</p></td>' .
' </tr>' .
'</table>';
mail($email , '-----------DELETED------------.ca Activation Email', $message , $headers );
$notice = "Your account was created successfully.<br>An email has been sent to the supplied email address, along with the activation link.<br>You must click the activation link before you are allowed to login to -----------DELETED------------.ca.<br>Thank-you for joining our online community!";
$complete = "1";
}
mysql_close();
}
if (!$complete){
?>
<table width="1100" border="0" align="center" cellpadding="10" cellspacing="0" background="images/body_bg.gif">
<tr>
<td height="400" colspan="3" valign="top"><p><strong>Register Your Free Account</strong></p>
<p>You are able to register an account with us absolutely free of charge. This entitles you to a basic membership, of course upgrades to your account are available depending on your needs. Please make sure you read the terms of use and privacy policy before filling out the registration form.</p>
<p>Please wait as this form continues to load all the default values for your registration. </p>
<table width="650" border="0" align="center" cellpadding="0" cellspacing="5" bgcolor="#333333">
<form name="registration" id="registration" action="registeraccount.php" method="post">
<? if ($notice) { ?>
<tr>
<td colspan="4"><div align="center"><?=$notice;?></div></td>
</tr>
<? } ?>
<tr>
<td width="95"><div align="right">Screen Name:</div></td>
<td width="209"><input name="screenname" type="text" class="textinput1" id="screenname" maxlength="25" tabindex="1" /></td>
<td width="110"><div align="right">Country:</div></td>
<td width="211"><select name="country" class="textinput1" id="country" onchange="querylocation('country')" tabindex="15">
<option selected="selected" value="<?=$Country?>"><?=$Country?></option>