- 分享
- 0
- 人气
- 0
- 主题
- 114
- 帖子
- 3964
- UID
- 209247
- 积分
- 8431
- 阅读权限
- 24
- 注册时间
- 2009-3-18
- 最后登录
- 2018-7-6
- 在线时间
- 7667 小时
    
|
本帖最后由 ★愛の恨★ 于 2013-6-29 03:24 PM 编辑
你终究不属于我 发表于 2013-6-29 02:34 PM 
你试试在你们的connection加print error的code,如果connect不到,run的时候,在网页上面会显示databas ...
请你看看一下这个是我们改过的
linking 的- <?php
- $root = realpath($_SERVER['DOCUMENT_ROOT'])."/tan/";
- $path = "http://localhost/Dbaase/login.php";
- $db = mysql_connect('localhost','root','1234','tan') or die(mysql_error());
- mysql_select_db("tan",$db) or die(mysql_error());
- ?>
复制代码 connect的- <?php
- session_start();
- include("linking.php");
- //localhost, username, password, database
- @ $db = new mysqli('localhost', 'root', '1234', 'tan');
- if (mysqli_connect_error())
- {
- echo 'Error: Could not connect to database. Please try again later.</br>数据库连接错误!请稍候重试。';
- exit;
- }
- ?>
复制代码 login 的- <?php
- session_start();
- if(isset($_POST["submit"]))
- {
- $username = $_POST["username"];
- $password = $_POST["password"];
-
- include ("connect.php");
-
- if($username != "" && $password != "")
- {
- $result = $db->query("SELECT username, password FROM user WHERE username = 'username' AND password = '$password'");
- if($result->num_rows == 1)
- {
- $row = $result->fetch_assoc();
- if($username == "admin")
- {
- //$_SESSION['admin'] = $row['adminName'];
- echo "<script language='javascript'>window.location='adminview.php'</script>";
- }else
- {
- echo "<script language='javascript'>window.location='studentview.php'</script>";
- }
- }
- else
- {
- echo "<script>alert('Please Check Your Admin ID And Password!')</script>";
- }
- }
- else
- {
- echo "<script>alert('Please Check Your Admin ID And Password!')</script>";
- }
- }
- ?>
- <html>
- <head>
-
- </head>
- <body>
- <form action='connect.php'>
- <center><img src="Southern UC.jpg" width="" height="" alt="Sounthern University College">
-
- <h1><p>
- <strong>Please enter user ID and password:</strong>
- <br>
- <strong>User ID</strong>
- <input type="text" size="20" name="username"></br>
- <strong>Password</strong>
- <input type="password" size="20" name="password">
- </p>
- <p>
- <strong>And then click this button:</strong>
- <input type="submit" name="submit" value="Login"></center>
- </p></h1>
- </form>
- </body>
- </html>
复制代码 |
|