dongyong3223 2013-08-14 21:40
浏览 50

PHP和MYSQL:Echo无法正常工作

I used to store all my data in 000webhost, today I decided to move to hostinger. So.. after moving it I replaced the old mysql_connect info by the new one. Alright, after doing that I tested it, everything has ran fine, except some echo functions.

check file (connects to the server and do the login):

    <?php

    $servidorr = "mysql.XXXX.co.uk";
    $bdd = "XXXXXXXX";
    $usuarioo = "XXXXX";
    $senhaa = "XXXXXXX";


    if (!empty($_POST) AND (empty($_POST['usuario']) OR empty($_POST['senha']))) {
        header("Location: geton"); exit;
    }


    mysql_connect($servidorr, $usuarioo, $senhaa) or trigger_error(mysql_error());

    mysql_select_db($bdd) or trigger_error(mysql_error());

    $usuario = mysql_real_escape_string($_POST['usuario']);
    $senha = mysql_real_escape_string($_POST['senha']);
    $lang = mysql_real_escape_string($_POST['lang']);


    $sql = "SELECT `id`, `nome`, `nivel` FROM `usuarios` WHERE (`usuario` = '". $usuario ."') AND (`senha` = '". sha1($senha) ."') AND (`ativo` = 1) LIMIT 1";
    $updatelang = "UPDATE usuarios SET lang='$lang' WHERE usuario='$usuario'";
    $query = mysql_query($sql);
    if (mysql_num_rows($query) != 1) {

        echo "<script>alert('Oops! Looks like there is something wrong with your login! *perhaps a typo or you did not fill out the fields*'); location.href='geton'</script>"; exit;
    } else {

        $resultado = mysql_fetch_assoc($query);
      mysql_query($updatelang);


        if (!isset($_SESSION)) session_start();

        $_SESSION['UsuarioID'] = $resultado['id'];
        $_SESSION['UsuarioNome'] = $resultado['nome'];
      $_SESSION['usuario'] = $resultado['usuario'];
        $_SESSION['UsuarioNivel'] = $resultado['nivel'];
      $_SESSION['lang'] = $resultado['lang'];

        header("Location: http://mapmaking.zz.mu/pages/home"); exit;
    }

    ?>


Home file (these echos are just for testing and this is not the original file, the original one has the same php stuff, except the echo functions, those are in random lines):

<?php


if (!isset($_SESSION)) session_start();

  $tlang = $_SESSION['UsuarioLang'];
  $aclevel = $_SESSION['UsuarioNivel'];
  $nick = $_SESSION['UsuarioNome'];

$neededal = 1;
if (!isset($_SESSION['UsuarioID']) OR ($_SESSION['UsuarioNivel'] < $neededal)) {
    session_destroy();
    header("Location: http://inside.mapmaking.uk.to/geton"); exit;


}

session_start();

echo $tlang;
echo $aclevel;
echo $nick;
echo "$level$tlang$tlang";


?>

[this one basically start the session and check if the connected user acess level is 1]

Echo $tlang does not work! :( somehow it doesn’t, I have no idea why ;_;

Hope you guys help me, thank you!!

  • 写回答

2条回答 默认 最新

  • douxiongzhen2126 2013-08-14 21:46
    关注

    $_SESSION['lang'] != $_SESSION['UsuarioLang']

    You assign a value to the first one, yet expect value from the second one.

    $_SESSION['lang'] = $resultado['lang'];

    $tlang = $_SESSION['UsuarioLang'];

    评论

报告相同问题?

悬赏问题

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