在xampp中使用MySQL的会话

时间:2015-04-09 11:31:52

标签: php session

当我想要开始会话时,我遇到了xampp的问题。我在MySQL数据库中创建了一个用户。我的签名表格引用了这个php脚本:

<?php
session_start();
?>
//...
<?php
$User = $_POST["User"];
$Pswd = $_POST["Pswd"];
//reference to current script $_SERVER['PHP_SELF'];
$con = open1($User, $Pswd);
if(isset($User)) {

    if (!empty($_POST['User']) && !empty($_POST['Pswd'])) {
        $username = mysqli_real_escape_string($con, $_POST['User']);    // get rid of special characters in 'User'
        $password = md5(mysqli_real_escape_string($con, $_POST['Pswd']));  // calculated md5 hash of the password string

        $checklogin = mysqli_query($con, "SELECT * FROM registrovany_uzivatel WHERE Uziv_jm = '" . $User . "' AND Heslo = '" . $Pswd . "'");

        if (mysqli_num_rows($checklogin) == 1) {
            //session_start();
            $row = mysqli_fetch_array($checklogin);
            $username = $row['User'];
            $email = $row['Email'];
            $name = $row['Name'];
            $surname = $row['Surname'];

            $_SESSION['Username'] = $username;
            $_SESSION['Email'] = $email;
            $_SESSION['Name'] = $name;
            $_SESSION['Surname'] = $surname;
            //session_id($_GET['PHPSESSID']);
            if (!isset($_SESSION['errors']))
                header('location: search_course.php');
            exit();         // Output a message and terminate the current script        
        }
    }
}
  

警告:session_start():会话ID太长或包含非法字符,有效字符为a-z,A-Z,0-9和&#39; - ,&#39;在第4行的C:\ xampp \ htdocs \ swscholar \ search_course.php

所以我将start_session()函数重命名为my_start_session(),这消除了会话ID中的字符(我在StackOverflow上找到了一个字符)但我在search_course脚本中出错了没有任何现有的$_SESSION设置。

0 个答案:

没有答案