dsfjk44656 2016-08-12 16:14
浏览 25

注册/注册按钮不起作用(PHP和AJAX)

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何将下列的“无限压缩存储器”设计出来
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭