Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Location
    Sutton-in-ashfield, Notts
    Posts
    117
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Form post on ajaxpage loading...

    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..

  • #2
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts
    Post more code, how are you validating?

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Location
    Sutton-in-ashfield, Notts
    Posts
    117
    Thanks
    7
    Thanked 0 Times in 0 Posts
    <?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();
    ?>

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    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.
    Are you a Help Vampire?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •