as far as the redirect goes I tried adding a header('location:') to the ajax script but all it does is load the new page inside the current page. here is my php code:
PHP Code:
<?php
include('../functions/index.php');
include('functions.php');
$results = mysql_query("SELECT Email Username FROM member") or die(mysql_error());
$row = mysql_fetch_array($results) or $row = array();
if (valid_captcha() == FALSE) $errors[] = "You did not enter the visual verifcation correctly!";
if (valid_username($_POST['Username'],$row)==FALSE)
{
$errors[] = 'Username is required and must be alpha-numeric';
}
if (strlen($_POST['First_name'])<2 || strlen($_POST['Last_name'])<2)
{
$errors[] = "First and Last name must be at least 2 characters long.";
}
if (strlen($_POST['Password'])<5 || $_POST['Password']=='' || alpha_numeric($_POST['Password'])==FALSE)
{
$errors[] = 'A password is required and must be alpha-numeric';
}
if ($_POST['Password']!=$_POST['re_Password'])
{
$errors[] = 'The two passwords must match';
}
if (valid_email($_POST['Email'],$row) == FALSE)
{
$errors[] = "The email address you entered is either invalid, or is currently in use.";
}
if(is_array($errors))
{
echo "<h1><img src=\"nogood.png\" alt=\"Error!\" />The Following Errors Occured</h1><ul>";
while (list($key,$value) = each($errors))
{
echo '<li>'.$value.'</li>';
}
echo "</ul>";
}
else {
foreach($_POST as $key => $value) $$key = $value;
$confirmnumber = rand(1000,9999);
$ip=$_SERVER['REMOTE_ADDR'];
$RegisteredDate = date('Y-m-d');
if($emailprivacy === "on") $emailprivacy = 1; else $emailprivacy = 0;
if($phoneprivacy === "on") $phoneprivacy = 1; else $phoneprivacy = 0;
if($genderprivacy === "on") $genderprivacy = 1; else $genderprivacy = 0;
if($Year !== -1 && $Month !== -1 && $Day !== -1) $birthday = "$Year-$Month-$Day";
$sql = "INSERT INTO `member`(`uscf`,`ipaddress`,`FirstName`,`LastName`,`Username`,`Password`,`Email`,`Gender`,`Birthday`,`DateRegistered`,
`Phone`,`Street1`,`Street2`,`City`,`State`,`Zip`,`ShowEmail`,`ShowGender`,`ShowPhone`,`ConfirmationNum`,`Confirmed`)
VALUES ('$uscf','$ip','$First_name','$Last_name','$username','$Password','$Email','$gender','$birthday','$RegisteredDate',
'$phone','$address1','$address2','$city','$state','$zip','$emailprivacy','$genderprivacy','$phoneprivacy','$confirmnumber',0)";
//mysql_query($sql) or die(mysql_error());
header('location: ../games');
}
?>
Code:
<script type="text/javascript">
window.addEvent('domready', function(){
$('registerForm').addEvent('submit', function(e) {
new Event(e).stop();
var log = $('log_res').empty().addClass('ajax-loading');
this.send({
update: log,
onComplete: function() {
log.removeClass('ajax-loading');
}
});
});
});
function go_now ()
{
window.location.href = "http://localhost/denverchess";
}
function theChecker()
{
if(document.getElementById("ToS").checked==false)
{
document.getElementById("submit").disabled=true;
}
else
{
document.getElementById("submit").disabled=false;
}
}
</script>
<div id="log">
<div id="log_res">
<!-- SPANNER -->
</div>
</div>
<form method="post" action="register.php" enctype="multipart/form-data" id="registerForm">
<input type="submit" id="submit" name="submit" value="Submit" disabled="true" onclick="javascript:scroll(0,0);" />
</form>
the javascript is here: http://denverchess.com/register/js/mootools.js dunno if its readable