doulu7921 2014-07-29 13:46
浏览 11
已采纳

由于条件的原因,在注册期间无法再登录

On my application users can upload avatars. They are not obliged to upload an avatar so I used a condition to check if users uploaded an avatar. But when I use this condition during the registration users can no longer log in to the application but I retrieve the data in my database. After the registration he sends me always to index.php

if (empty($_FILES['upload']['name'])) {
    $user->PPName = "";
    $user->PPNewName = "";
    $user->Register();
} else {
    $PPNewName = time() . $_FILES['upload']['name'];
    move_uploaded_file($_FILES['upload']['tmp_name'], "uploads/" . $PPNewName);
    $user->PPName = mysql_real_escape_string($_FILES['upload']['name']);
    $user->PPNewName = $PPNewName;
    $user->Register();
}

function (register and loggin in at the same time)

public function Register()
{
    // register, salt gebruiken voor het beveiligen van het wachtwoord.
    $salt = "ab4p73wo5n3ig247xb1w9r";
    $db = new Db();
    // gegevens invoeren in de databank
    $insert = "INSERT INTO tblusers (
                          name,
                          email,
                          password,
                          surname,
                          avatar,
                          status,
                          current_challenge_id,
                          feeling

                      ) VALUES (
                          '" . $db->conn->real_escape_string($this->m_sName) . "',
                          '" . $db->conn->real_escape_string($this->m_sEmail) . "',
                          '". $db->conn->real_escape_string(md5($this->m_sPassword . $salt)) . "',
                           '" . $db->conn->real_escape_string($this->m_sSurname) . "',
                          '" . $db -> conn -> real_escape_string($this -> m_sPPNewName) . "',
                              '" . $db -> conn -> real_escape_string("user") . "',
                               '" . $db -> conn -> real_escape_string("1") . "',
                               '" . $db -> conn -> real_escape_string("goed") . "'

                      )";
    $select = "SELECT * FROM tblusers WHERE email = '" . $db->conn->real_escape_string($this->Email) . "';";
    $result = $db->conn->query($select);
    //echo $result;
    if($result->num_rows == 0)
    {
        $db->conn->query($insert);
        //session_start();
        // Inloggen, name in session meegeven, exception tonen die weergeeft dat je bent geregistreerd
        $_SESSION["loggedin"] = true;
        $_SESSION["name"] = $this->Name;
        $_SESSION["email"] = $this->Email;
        //throw new Exception("Signed up!");
        header("Location: challenge.php?challenge_id=1" );
    }

    else {
        // Bij eerder gebruikte email
        throw new Exception("I'm sorry, your e-mailadres already exist");
    }

}    
  • 写回答

1条回答 默认 最新

  • douxidao3524 2014-07-29 14:04
    关注

    Dit you start the session in the challenge.php page?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择