• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AJAX login problem

#1
[eluser]Robb__[/eluser]
I'm creating a "simple" login function. My site contains no nuclear secrets why the security (and logic?) of what I'm trying to do can be questioned. I'm trying to get the login and register process to work without reloading, i.e through AJAX.

Somehow, the return values from all of this is "undefined" at best, but most of the time nothing happens. I have searched for errors, but can't figure out what is wrong.


Code:
var size = registerform.length;
var form = new Array(size);
form = registerform;
var firstname = form[0];
var lastname = form[1];
var mail = form[2];
var user = form[3];
var passw = form[4];

var myAjax9 = new Ajax.Request('mydomain/index.php/application/register/' + firstname  + "/" + lastname + "/" + mail + "/" + user + "/" + passw ,{onComplete:registration_response});

In controller application.php
Code:
function register($first, $last, $mail, $user, $passw)
{  

$newdata= array(
       'username'  => $user,
       'email'  => $mail,
       'logged_in' => TRUE
      );
$this->load->library('session');
$this->session->set_userdata($newdata);

   $this->load->model('Load');
   $this->Load->register($first, $last, $mail, $user, $passw);
  
  $response = 'var name = "';
  $response .= $first;
   $response .= '"';

  $response .= 'var user = "';
  $response .= $user;
   $response .= '"';
$response = rtrim($response);

echo $response;
  
  }

In model load.php
Code:
function register ($firstname, $lastname, $email, $username, $password)
  {
  $this->load->database();
  $sql = "INSERT INTO `user` ( `Nickname` , `Firstname` , `Lastname` , `Password` , `Email` ) VALUES ('" .$username ."', '" .$firstname ."', '" .$lastname ."','" .$password ."', '" .$email ."');";
  $query = $this->db->query($sql);  
  
    
  }

Handles the AJAX response
Code:
function registration_response(response) {
eval(response.responseText);
var name = name;
var user = user;
newInner2 = "<h3>Welcome";
newInner2 += name;
newInner2 += "!</h3>";
newInner3 ="<h5 align='left'><font color='#C0C0C0'>Log out</font></h5>";
newInner3 +="<h5 align='left'><font color='#C0C0C0'>"
newInner3 += user;
newInner3 +="</font></h5>";

document.getElementById("overlay8")[removed] = newInner2;
document.getElementById("inlog")[removed] = newInner3;

YAHOO.lager.container.overlay8.show()
setTimeout("YAHOO.lager.container.overlay8.hide();",1500);

   }


Messages In This Thread
AJAX login problem - by El Forum - 07-23-2007, 05:28 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.