想了解php–如何完成此登录脚本?的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于php做登录的相关问题,此外,我们还将为您介绍关于43.监控用户登录脚本、FTP自动登录脚本文件、Jmete
想了解php – 如何完成此登录脚本?的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于php做登录的相关问题,此外,我们还将为您介绍关于43.监控用户登录脚本、FTP自动登录脚本文件、Jmeter之登录脚本录制及调试、linux ssh 登录脚本的新知识。
本文目录一览:php – 如何完成此登录脚本?(php做登录)
这是我的脚本文件.
> index.PHP:
<html> <body> <form action="action1.PHP" method="post"> Username: <input type="text" name="uname"> Password: <input type="password" name="pword"> <input type="submit"> </form> </body> </html>
index.PHP文件只是我用来从我的用户收集信息以进行注册的页面.
> action1.PHP:
<?PHP $con = MysqL_connect("localhost","root",""); if (!$con) { die ('Could not connect: ' . MysqL_error()); } MysqL_select_db("user1",$con); $sql="INSERT INTO useri1 (uname,pword) VALUES ('$_POST[uname]','$_POST[pword]')"; if (!MysqL_query($sql,$con)) { die('Error: ' . MysqL_error()); } echo "1 record added"; MysqL_close($con); ?>
action1.PHP文件只是将用户注册到数据库的页面.
> login.PHP:
<html> <body> <form action="checklogin.PHP" method="post"> Username: <input type="text" name="uname1"> Password: <input type="password" name="pword1"> <input type="submit"> </form> </body> </html>
login.PHP文件就是我用来输入用户登录信息的页面.
现在这是我的问题,我不知道如何检查用户登录信息,以便他们可以进入仅限会员区域.我是新手&任何帮助是极大的赞赏.
谢谢,
–Devin
解决方法
<?PHP session_start(); $MysqLi = new MysqLi('localhost','root',DB_PASSWORD,'user1'); /* check connection */ if ($MysqLi->connect_error) die('Connect Error (' . $MysqLi->connect_errno . ') ' . $MysqLi->connect_error); /* escape string from sql injection */ $userName = $MysqLi->real_escape_string($_POST['uname1']); /* query database */ $result = $MysqLi->query("SELECT `pword` FROM `user1` WHERE `uname` = '".$userName."'"); if ($result->num_rows == 1) { while ($col = $result->fetch_array(MysqLI_ASSOC)) { // This presumes you're storing your passwords in plain text. // If you hashed your passwords or anything,you would have to do the same to $_POST['pword'] if ($_POST['pword'] == $col['pword']) { // You Could do anything here,but sessions are a way of keeping track of a user. $_SESSION['userName'] = $_POST['uname1']; $_SESSION['loggedIn'] = true; } } } $result->close(); /* don't forget to close the connection */ $MysqLi->close(); ?>
43.监控用户登录脚本
思路:while 死循环加if判断语句30秒判断一次用户登录信息
#!/bin/bash
read -p "please input a username : " user
while :
do
if who |grep -qw "$user" ;then #grep -q 不显示输出信息 -w 精确查找
echo "$user is login!"
exit#退出循环
else
echo -e "$user does not exist!\nMonitoring..."
fi
sleep 30#睡眠30秒
done
FTP自动登录脚本文件
FTP自动登录脚本文件 |
-s:script file路径 注意:冒号后不能跟空格,路径含空格时,需用双引号括起来. |
C:\Users\Administrator>type ins.sf
C:\Users\Administrator>ftp -s:ins.sf ftp> |
C:\Users\Administrator>type D:\.1\ins.sf
C:\Users\Administrator>ftp -s:D:\.1\ins.sf ftp> |
C:\Users\Administrator>type "D:\.1\ins 2.sf"
C:\Users\Administrator>ftp -s:"D:\.1\ins 2.sf" ftp> |
C:\Users\Administrator>dir /b ins.sf File Not Found
C:\Users\Administrator>ftp -s:ins.sf Error opening script file ins.sf.
Transfers files to and from a computer runni… |
C:\Users\Administrator>type ins.sf
C:\Users\Administrator>ftp -s: ins.sf
Transfers files to and from a computer runnin… |
C:\Users\Administrator>type D:\.1\ins.sf
C:\Users\Administrator>ftp -s: D:\.1\ins.sf
Transfers files to and from a computer runnin… |
C:\Users\Administrator>type "D:\.1\ins 2.sf"
C:\Users\Administrator>ftp -s: "D:\.1\ins 2.sf"
Transfers files to and from a computer running an… |
C:\Users\Administrator>type ins.sf open localhost wangxd 123456 pwd C:\Users\Administrator>ftp -s:ins.sf ftp> open localhost Connected to RMS365. 220 Service ready for new user. User (RMS365:(none)): 331 User name okay, need password for wangxd.
230 User logged in, proceed. ftp> pwd 257 "/" is current directory. ftp> |
说明:实际上该文件书写的就是我们平时使用ftp命令操作时的每行命令。 |
C:\Users\Administrator>type ins.sf open localhost laiye
pwd C:\Users\Administrator>ftp -s:ins.sf ftp> open localhost Connected to RMS365. 220 Service ready for new user. User (RMS365:(none)): 331 User name okay, need password for laiye.
230 User logged in, proceed. ftp> pwd 257 "/" is current directory. ftp> |
注意:密码为空时,用空行代替。 |
C:\Users\Administrator>type ins.sf open localhost laiye
pwd pwd
pwd C:\Users\Administrator>ftp -s:ins.sf ftp> open localhost Connected to RMS365. 220 Service ready for new user. User (RMS365:(none)): 331 User name okay, need password for laiye.
230 User logged in, proceed. ftp> pwd 257 "/" is current directory. ftp> pwd 257 "/" is current directory. ftp> ftp> pwd 257 "/" is current directory. ftp> |
注意:每个回车都会被解析。 |
C:\Users\Administrator>ftp localhost Connected to RMS365. 220 Service ready for new user. User (RMS365:(none)): |
C:\Users\Administrator>ftp localhost Connected to RMS365. 220 Service ready for new user. User (RMS365:(none)): wangxd 331 User name okay, need password for wangxd. Password: 230 User logged in, proceed. ftp> pwd 257 "/" is current directory. ftp> |
C:\Users\Administrator>ftp -n localhost Connected to RMS365. 220 Service ready for new user. ftp> |
C:\Users\Administrator>ftp -n localhost Connected to RMS365. 220 Service ready for new user. ftp> user wangxd 123456 331 User name okay, need password for wangxd. 230 User logged in, proceed. ftp> pwd 257 "/" is current directory. ftp> |
C:\Users\Administrator>ftp -n localhost Connected to RMS365. 220 Service ready for new user. ftp> user laiye 331 User name okay, need password for laiye. Password: 230 User logged in, proceed. ftp> |
C:\Users\Administrator>ftp -n localhost Connected to RMS365. 220 Service ready for new user. ftp> user laiye " " 331 User name okay, need password for laiye. 230 User logged in, proceed. ftp> |
C:\Users\Administrator>ftp -n localhost Connected to RMS365. 220 Service ready for new user. ftp> user laiye "" 331 User name okay, need password for laiye. Password: 230 User logged in, proceed. ftp> |
C:\Users\Administrator>type ins.sf open localhost user wangxd 123456 pwd C:\Users\Administrator>ftp -n -s:ins.sf ftp> open localhost Connected to RMS365. 220 Service ready for new user. ftp> user wangxd 123456 331 User name okay, need password for wangxd. 230 User logged in, proceed. ftp> pwd 257 "/" is current directory. ftp> |
C:\Users\Administrator>type ins.sf open localhost user laiye
pwd C:\Users\Administrator>ftp -n -s:ins.sf ftp> open localhost Connected to RMS365. 220 Service ready for new user. ftp> user laiye 331 User name okay, need password for laiye.
230 User logged in, proceed. ftp> pwd 257 "/" is current directory. ftp> |
注意:使用-n可以在初始连接时禁止自动登录。此时登录方式为:user 用户名 密码,密码为空时,用双引号扩起来的空格代替,或者将密码在新行中书写,仅用双引号是无法登录的,仍然会要求输入密码。 |
附件1
Jmeter之登录脚本录制及调试
根据上文中,都配置好以后就可以开始启动了,点击启动,线程组里面就会开始记录你的网页请求。这里使用CNode网站做测试。我分别记录进行了“登入”,“话题创建”,“话题编辑”的测试。看下线程组的记录情况。
没有启动之前,我们的网页是上不了网,所有打开登入页面,输入账号密码,就会显示“你尚未连接网络”。然后去点击jmeter的启动,点击弹窗【ok】,回到网页,发现网页在慢慢登入了。
当我在cnode登入之后,线程组会记录和很多,signin就是登入信息,右边直接记录了账号密码。
紧接着我又,进行创建一个话题,标题为111111111111111111,内容为111111111111111111,类型为ask。
然后,有对这个话题进行编辑,内容改成11222222222222222。线程组也进行了记录。
然后我新建立一个线程组,把登入”,“话题创建”,“话题编辑”的三个请求单独复制出来了。但是添加【结果树】后,一执行,发现,只有只有登入请求成功,创建话题的编辑话题都是失败,这是什么原因呢?提示[no cookies],咋解决??
linux ssh 登录脚本
最近公司的积分商城被人刷票。所以要查nginx日志,而这个业务就有8台服务器。每次登录都要输入密码。那个蛋疼。所以写了一个自动化登录的shell脚本。省去了很多麻烦。这个只是一个小功能,如果想做的更加智能化,可以在这个基础上优化
#!/usr/bin/expect
set timeout 5
set user xxx
set passwd xxx
set host [lindex $argv 0]
spawn ssh $user@$host
expect "*assword:" {
send "$passwd\r"
}
interact
当然也可以把此脚本当shell命令使用,只需要 cp addServer.sh /bin/addServer 就行了。
下回调用时直接用 addServer 10.x.x.x ,很是方便吧
注意:
1,/usr/bin/expect 不支持shell赋值(调试了好久,蛋疼)
2,interact不可少(执行完成后保持交互状态,把控制权交给控制台,这个时候就可以手工操作了。如果没有这一句登录完成后会退出,而不是留在远程终端上)
参考:
http://www.xuanhao360.com/linux-expects/
http://www.pythonclub.org/linux/expect
http://www.godblessyuan.com/2015/02/25/shell_expect_ssh/
关于php – 如何完成此登录脚本?和php做登录的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于43.监控用户登录脚本、FTP自动登录脚本文件、Jmeter之登录脚本录制及调试、linux ssh 登录脚本等相关内容,可以在本站寻找。
本文标签: