美好的一天,这是我第一次在这里发帖。插入PHP代码时,我的页面响应时间过长:
<?php
include("config.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from form
$myusername = mysqli_real_escape_string($db,$_POST['username']);
$mypassword = mysqli_real_escape_string($db,$_POST['password']);
$sql = "SELECT * FROM Administrators WHERE username = '$myusername' and password = '$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: index.html");
}else {
$error = "Your User Name or Password is invalid";
}
}
?>
答案 0 :(得分:0)
microtime(1);
; EXPLAIN
,在mysql中运行整个查询以查看它是否花费了太多时间。EXPLAIN SELECT * FROM Administrators WHERE username = 'myusername' and password = 'mypassword';