The register button doesn't work. Once I complete the registraiton it just sits there and nothing happens.
I pressed the F12 button to see the errors and it showed this:(Internal Server Error)http://localhost/users/ajax_join Failed to load resource: the server responded with a status of 500 (Internal Server Error)
My register php page:
<?php require_once ('header.php'); ?>
<div class="span4 offset3">
<div class="page-header">
<h1>Join Now. It's Free!</h1>
<form method="post" action="/users/ajax_join" id="signup-form" accept-charset="UTF-8">
<label>
Username:
</label>
<input type="text" name="username" placeholder="username" class="required"/>
<br/>
<label>
Email:
</label>
<input type="email" name="email" placeholder="email" class="required" />
<br/>
<label>
Password:
</label>
<input type="password" name="password" placeholder="****" class="required" />
<br/>
<input type="submit" name="sb_signup" value="Join Now" class="btn btn-warning"/>
</form>
<div id="signup_output_div"></div>
</div>
</div>
<div class="span2"></div>
<?php require_once 'sidebar.php'; ?>
<?php require_once ('footer.php'); ?>
users.php:
/*
* Register Form/Page
*/
public function join() {
if($this->loggedIn)
{
redirect('/users');
exit;
}
$this->load->view('join-now');
}
/*
* Register via AJAX
*/
public function ajax_join() {
if($this->input->post('sb_signup')) {
unset($_POST['sb_signup']);
$insert = array();
foreach($this->input->post() as $k=>$v) {
if($this->input->post($k, TRUE) != "") {
$insert[$k] = $this->input->post($k, TRUE);
}else{
print '<div class="alert alert-warning">';
print 'All fields are mandatory';
print '</div>';
exit;
}
}
$this->db->where(array("username" => $this->input->post('username', TRUE)));
$this->db->or_where(array("email" => $this->input->post('email', TRUE)));
$user = $this->db->get("users");
if(count($user->result())) {
print '<div class="alert alert-warning">';
print 'Username/Email taken, please chose another one.';
print '</div>';
exit;
}
$insert['ip'] = ip2long($_SERVER['REMOTE_ADDR']);
$insert['password'] = md5($insert['password']);
if($this->db->insert("users", $insert)) {
$this->session->set_userdata('loggedIn', $this->db->insert_id());
print '<div class="alert alert-success">';
print 'You are now logged in. <a href="/users">My Account</a>';
print '</div>';
}else{
print '<div class="alert alert-warning">';
print 'DB Error';
print '</div>';
}
}else{
print '<div class="alert alert-warning">';
print '-No post-';
print '</div>';
}
}
Help me