Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我必须对以下代码进行哪些更改才能使用引导设置样式。?_Php_Twitter Bootstrap - Fatal编程技术网

Php 我必须对以下代码进行哪些更改才能使用引导设置样式。?

Php 我必须对以下代码进行哪些更改才能使用引导设置样式。?,php,twitter-bootstrap,Php,Twitter Bootstrap,通常我只会使用基本的PHP和MySQL以及一些简单的CSS来设计样式。然而,我喜欢引导框架的外观和感觉,并希望将其整合到我的PHP中,但我对从哪里开始比较陌生。我想从一个简单的实际例子开始 使用下面的代码,这是一个使用PHP和MySQL的简单登录脚本,为了使用Bootstrap,我需要做哪些更改 我已经下载了引导文件 <?php $connect = mysqli_connect("db location","username","password", "forks") or die(

通常我只会使用基本的PHP和MySQL以及一些简单的CSS来设计样式。然而,我喜欢引导框架的外观和感觉,并希望将其整合到我的PHP中,但我对从哪里开始比较陌生。我想从一个简单的实际例子开始

使用下面的代码,这是一个使用PHP和MySQL的简单登录脚本,为了使用Bootstrap,我需要做哪些更改

我已经下载了引导文件

<?php  
$connect = mysqli_connect("db location","username","password", "forks") or die(mysql_error()); 


if(isset($_COOKIE['ID_your_site'])){ //if there is, it logs you in and directes you to the members page
    $username = $_COOKIE['ID_site']; 
    $pass = $_COOKIE['Key_site'];
    $check = mysqli_query($conect, "SELECT * FROM users WHERE username = '$username'")or die(mysql_error());

    while($info = mysqli_fetch_array( $check )){
        if ($pass != $info['password']){}
        else{
            header("Location: login.php");
        }
    }
 }

 //if the login form is submitted 
 if (isset($_POST['submit'])) {

    // makes sure they filled it in
    if(!$_POST['username']){
        die('You did not fill in a username.');
    }
    if(!$_POST['pass']){
        die('You did not fill in a password.');
    }

    // checks it against the database
    if (!get_magic_quotes_gpc()){
        $_POST['email'] = addslashes($_POST['email']);
    }

    $check = mysqli_query($conect, "SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());

 //Gives error if user dosen't exist
 $check2 = mysqli_num_rows($check);
 if ($check2 == 0){
    die('That user does not exist in our database.<br /><br />If you think this is wrong <a href="login.php">try again</a>.');
}

while($info = mysqli_fetch_array( $check )){
    $_POST['pass'] = stripslashes($_POST['pass']);
    $info['password'] = stripslashes($info['password']);
    $_POST['pass'] = md5($_POST['pass']);

    //gives error if the password is wrong
    if ($_POST['pass'] != $info['password']){
        die('Incorrect password, please <a href="login.php">try again</a>.');
    }

    else{ // if login is ok then we add a cookie 
        $_POST['username'] = stripslashes($_POST['username']); 
        $hour = time() + 3600; 
        setcookie(ID_your_site, $_POST['username'], $hour); 
        setcookie(Key_your_site, $_POST['pass'], $hour);     

        //then redirect them to the members area 
        header("Location: members.php"); 
    }
}
}
else{
// if they are not logged in 
?>

 <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">  
 <table border="0">  
 <tr><td colspan=2><h1>Login</h1></td></tr>  
 <tr><td>Username:</td><td>  
 <input type="text" name="username" maxlength="40">  
 </td></tr>  
 <tr><td>Password:</td><td>  
 <input type="password" name="pass" maxlength="50">   
 </td></tr> 

 <tr><td colspan="2" align="right">  
 <input type="submit" name="submit" value="Login">  
 </td></tr>  
 </table>  
 </form> 

 <?php 
 }
 ?> 

从脚本中的安全问题中可以查看:

如果您查看源代码,您将看到熟悉的

资料来源:

<!-- here your php code -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Signin Template for Bootstrap</title>

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">

  </head>

  <body>

    <div class="container">

      <form class="form-signin" action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
        <h2 class="form-signin-heading">Please sign in</h2>
        <label for="inputEmail" class="sr-only">Email address</label>
        <input type="email" id="inputEmail" class="form-control" placeholder="Email address" name="username" required autofocus>
        <label for="inputPassword" class="sr-only">Password</label>
        <input type="password" id="inputPassword" name="pass" class="form-control" placeholder="Password" required>
        <div class="checkbox">
          <label>
            <input type="checkbox" value="remember-me"> Remember me
          </label>
        </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
      </form>

    </div>
  </body>
</html>

引导的登录模板
您真的不应该使用PHP来处理密码安全性。在散列之前,请确保您在它们上安装或使用任何其他清理机制。这样做会更改密码并导致不必要的额外编码。表示了解的语句。即使是这样也不安全@熟悉的杰布兰查德(见)