...

View Full Version : Form post on ajaxpage loading...



Idfk
06-30-2010, 02:35 PM
Ive got a register form on a ajax page and i want to know how to make it post it in ajax to the same page with echo " onClick=\"ajaxpage('$path/register', 'think'); return false\" ";

Thanks..

sybil6
06-30-2010, 03:26 PM
Post more code, how are you validating?

Idfk
06-30-2010, 04:57 PM
<?php
ob_start();
include '../includes/config.php';
?>
<?php
if($in[username]){
echo "It appears you are already logged in as <b><a href=\"$path/#\" onClick=\"ajaxpage('$path/profile/$in[username]', 'think'); return false\">Back</a></b>!<br /><a href=\"$path/#\" onClick=\"ajaxpage('$path/thinkhabbo/hone', 'think'); return false\">Home</a>";
}elseif($_POST['register']){
$user = strip_tags($_POST['user']);
$pass1 = md5(strip_tags($_POST['pass1']));
$pass2 = md5(strip_tags($_POST['pass2']));
$email1 = strip_tags($_POST['email1']);
$email2 = strip_tags($_POST['email2']);
$habboname = strip_tags($_POST['habboname']);
$rank = strip_tags($_POST['rank']);
$joindate = date("F jS Y");
$rank = date("1");
$ip = $_SERVER['REMOTE_ADDR'];
if(!$user || !$pass1 || !$pass2 || !$email1 || !$email2 || !$habboname || !$rank){
echo "All fields are required!<br /><a href=\"$path/#\" onClick=\"ajaxpage('$path/register', 'think'); return false\">Back</a>";
}else{
if($pass1 != $pass2){
echo "The two passwords do not match!<br /><a href=\"$path/#\" onClick=\"ajaxpage('$path/register', 'think'); return false\">Back</a>";
}else{
if($email1 != $email2){
echo "The two E-Mail addresses do not match!<br /><a href=\"$path/#\" onClick=\"ajaxpage('$path/register', 'think'); return false\">Back</a>";
}else{
if(strpos($email1, ".") == false || strpos($email1, "@") == false || strpos($email2, ".") == false || strpos($email2, ".") == false){
echo "You must enter a valid E-Mail!<br /><a href=\"$path/#\" onClick=\"ajaxpage('$path/register', 'think'); return false\">Back</a>";
}else{
$check_user = mysql_query("SELECT * FROM users WHERE `username` = '$user'");
$check_email = mysql_query("SELECT * FROM users WHERE `email` = '$email1'");
if(mysql_num_rows($check_user) == 1){
echo "The user <b>'.$user.'</b> already exists!<br /><a href=\"$path/#\" onClick=\"ajaxpage('$path/register', 'think'); return false\">Back</a>";
}else{
if(mysql_num_rows($check_email) == 1){
echo "A user has already registered with the email <b>$email1</b><br /><a href=\"$path/#\" onClick=\"ajaxpage('$path/register', 'think'); return false\">Back</a>";
}else{
mysql_query("INSERT INTO `users` (`username`, `pass`, `email`, `ip`, `joindate`, `habboname`, `rank`) VALUES ('$user', '$pass1', '$email1', '$ip', '$joindate', '$habboname', '$rank');");
echo "You have successfully registered as <b><a href=\"$path/#\" onClick=\"ajaxpage('$path/profile/$user', 'think'); return false\">Back</a></b>!";
if($reg_email == '1'){
mail($email1, 'Registration at '.$site[title], 'You have registered at '.$site[title].' as '.$user.'!', 'From: '.$admin.' <no.reply@'.$_SERVER['SERVER_NAME'].'>') or die('We could not send an E-Mail to '.$email1.'!');
}
}
}
}
}
}
}
}else{
echo "<form method=\"post\" action=\"register\">
<table>
<tr>
<td><label>Username:</label></td>
<td><input type=\"text\" name=\"user\" size=\"40\" maxlength=\"30\"></td>
</tr>
<tr>
<td><label>Password:</label></td>
<td><input type=\"password\" name=\"pass1\" size=\"40\" maxlength=\"40\"></td>
</tr>
<tr>
<td><label>Confirm Password:</label></td>
<td><input type=\"password\" name=\"pass2\" size=\"40\" maxlength=\"40\"></td>
</tr>
<tr>
<td><label>E-Mail Address:</label></td>
<td><input type=\"text\" name=\"email1\" size=\"40\" maxlength=\"150\"></td>
</tr>
<tr>
<td><label>Confirm E-Mail Address:</label></td>
<td><input type=\"text\" name=\"email2\" size=\"40\" maxlength=\"150\"></td>
</tr>
<tr>
<td><label>HabboName:</label></td>
<td><input type=\"text\" name=\"habboname\" size=\"40\" maxlength=\"150\"></td>
</tr>
</table>
<input type=\"submit\" name=\"register\" value=\"Register\">
</form>";
}
?>
<?php
ob_flush();
?>

tomws
06-30-2010, 05:00 PM
If you want people to take the time to help, then instead of dumping an unreadable wall of code, take 2 seconds and wrap it in the appropriate code tags (http://www.codingforums.com/showthread.php?t=68462).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum