dtcyv3985 2016-09-02 14:19
浏览 23

PHP登录脚本给出内部错误

I am trying to create a very basic log in script for a website only used by a select group of people.

I have created the HTML form and mysql database with the relevant log ins etc, however when I try the site on my server, once the form is submitted and it redirects me to my login.php, it throws up a 500 Intrernal Server Error.

Here are the php files: login.php

<?php
   include("config.php");
   session_start();

   if($_SERVER["REQUEST_METHOD"] == "POST") {

      $myusername = mysqli_real_escape_string($db,$_POST['username']);
      $mypassword = mysqli_real_escape_string($db,$_POST['password']); 

      $sql = "SELECT id FROM admin WHERE username = '$myusername' and passcode = '$mypassword'";
      $result = mysqli_query($db,$sql);
      $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
      $active = $row['active'];

      $count = mysqli_num_rows($result);

      // If result matched $myusername and $mypassword, table row must be 1 row

      if($count == 1) {
         session_register("myusername");
         $_SESSION['login_user'] = $myusername;

         header("location: welcome.php");
      }else {
         $error = "Your Login Name or Password is invalid";
      }
   }
?>

config.php

<?php
   define('DB_SERVER', '*****');
   define('DB_USERNAME', '***');
   define('DB_PASSWORD', '***');
   define('DB_DATABASE', '****');
   $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
?>

(Obviously I have removed the database information for this purpose). Any advice would be greatly appreciated, I have spent hours trawling the internet, trying different scripts or solutions and watching tutorials.

Please be gentle, I'm new to all this. Thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 易康econgnition精度验证
    • ¥15 线程问题判断多次进入
    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致