dongwen6743 2015-01-16 00:24
浏览 26


How to post values to loginchk_coustomer.php given in below code, not through Url by any other way. Is there any other way to post these value to loginchk_coustomer.php becoz it is not secure.

include "include/connect.php";
$user_name       = $_REQUEST['user_name'];
$password        = $_REQUEST['password'];
//echo "select * from school_info where school_id='$user_name' and school_password='$password'";
$sql_query       = mysql_fetch_assoc(mysql_query("select * from school_info where school_id='$user_name' and school_password='$password'"));
$db_username     = $sql_query['db_username'];
$db_password     = $sql_query['db_password'];
$db_databasename = $sql_query['db_databasename'];

echo "<script>";
echo "self.location='member/loginchk_customer.php?db_username=$db_username&db_password=$db_password&db_databasename=$db_databasename&user_name=$user_name&password=$password'"; // Comment this line if you don't want to redirect
echo "</script>";


  • 写回答

1条回答 默认 最新

  • dongshanxiao7328 2015-01-16 01:00

    You need to create a session to store all that information.

    Here's what they are - from

    Session support in PHP consists of a way to preserve certain data across subsequent accesses.

    To start a session write at the beginning of your code:

    session_start(); // needed in all pages that will use the variables below

    and then after your assign the information this way:

    $_SESSION['username'] = $sql_query['db_username'];
    $_SESSION['password'] = $sql_query['db_password'];
    $_SESSION['databasename'] = $sql_query['db_databasename'];

    All the information will persist on those variables along the site until you do:


    I also recommend you not to redirect with javascript, but this way in PHP:

    header('Location: member/loginchk_customer.php');

    Possibly after checking this answer you will think about to change the way you check the login information. But that's okay. It's the way of learning.

    More information about sessions:

    I hope this helps.

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



  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题