电脑安全

您当前的位置:主页 > 电脑安全 >

php登陆问题[txt保存数据]-网络编程

来源:[db:来源]标题:   foreach    编辑:电脑技术全能网 时间:2019-09-22 06:22

原标题:php登陆问题[txt保存数据]-网络编程
   <?php if ( $_SERVER [ 'REQUEST_METHOD' ]== "POST" ){ // Get UserNames and Passwords. $Logi = file ( "users/log.txt" ); // Work out how many there are $size = sizeof ( $Logi ); // Break apart passwords and usernames foreach( $Logi as $Key => $Val ) { $Data [ $Key ] = explode ( "||" , $Val ); } // run through list and see if any match for( $K = 0 ; $K < $size ; $K ++) { $user = $Data [ $K ][ 0 ]; $pass = $Data [ $K ][ 1 ]; // If match set cookie and redirect. if ( $user == trim ( addslashes ( $_POST [ "user" ])) && $pass == trim ( addslashes ( $_POST [ "pass" ])) ) { setcookie ( "in" , 1 , time ()+ 3600 ); // Start hidden page header ( "Location: www.dnjishu.com" ); } } echo "Login Failed." ; // If you didnt log in show login form } else { ?> <div style="width:250px"> <div><strong>Black Sheep E-Team Login</strong></div> <div><form name="Login" method="post" action=" <?=$_SERVER [ 'PHP_SELF' ]; ?> "> <div align="right">Username: <input name="user" type="text" > <br> Password: <input name="pass" type="password" > <br> <input type="submit" name="Submit" value="Submit"> </div> </form> </div></div> <?php } ?>

上一篇:php 保存远程服务器上图片-网络编程

下一篇:没有了