我認爲,form概念主要區分於table,table是用網頁佈局設計,是靜態的,form是用於顯示和收集信息傳遞到服務器和後臺數據庫中,是動態的; 如下是表單的百度百科: 表單在網頁中主要負責數據採集功能。一個表單有三個基本組成部分: 表單標籤:這裏麪包含了處理表單數據所用CGI程序的URL以及數據提交到服務器的方法。 表單域:包含了文本框、密碼框、隱藏域、多行文本框、複選框、單選框、下拉選擇框和文件上傳框等。 表單按鈕:包括提交按鈕、復位按鈕和通常按鈕;用於將數據傳送到服務器上的CGI腳本或者取消輸入,還能夠用表單按鈕來控制其餘定義了處理腳本的處理工做。
HTML(超文本標記語言)、XML(可擴展標記語言)以及Python、PHP、JavaScript、ASP等衆多腳本語言。
JavaScript、ASP、PHP、Ruby等腳本語言,ASP基於IIS WEB PHP基於APACHE WEB
學習了html,jsp,php等語言的使用,學到了不少有用的東西,也把學到的數據庫中的知識實踐了。網頁編程頗有趣~javascript
靜態網頁php
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>課程教學管理系統</title> </head> <body style= "background: url(1.png)"> <div class="form-div"> <form id="login" name="login" method="post" action="#"> <table > <tr> <th colspan="2">課程教學管理系統登陸頁面</th> </tr> <tr> <td align="right">用戶名:</td> <td><input type="text" name="usrname" size="20"></td> </tr> <tr> <td align="right">密碼:</td> <td><input type="password" name="password" size="20" ></td> </tr> <tr> <td align="right">身份:</td> <td align="center"> <input type="radio" name="identity" value="teacher">教師 <input type="radio" name="identity" value="student" checked>學生 </td> </tr> <tr> <td align="center"><input type="submit" value="登陸" onsubmit="code_isRight()"></td> <td align="center"><input type="button" value="註冊" onclick="jump2register()"></td> <td><input type="reset" name="rs" value="重置" /></td> </tr> </table> </form> </body> </html>
動態網頁,代碼中包含功能函數。html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>課程教學管理系統</title> <script language="javascript"> function jump2register(){ location.href="register.html"; } </script> </head> <body style= "background: url(1.png) repeat-x #fff;"> <table> <form method ="POST" action="#" name="Login" > <th colspan="2">課程教學管理系統登陸頁面</th> <tr> <td>用戶名:</td> <td><input type="text" name="username" value="Your name" size="20" maxlength="20" onfocus="if (this.value=='Your name') this.value='';" /></td> <td> </td> <td> </td> </tr> <tr> <td>密 碼:</td> <td><input type="password" name="password" value="Your password" size="20" maxlength="20" onfocus="if (this.value=='Your password') this.value='';" /></td> <td> </td> <td> </td> </tr> <tr> <td align="right">身份:</td> <td align="center"> <input type="radio" name="identity" value="teacher">教師 <input type="radio" name="identity" value="student" checked>學生 </td> </tr> <tr> <td><input type="checkbox" name="zlogin" value="1">自動登陸</td> </tr> <table> <tr> <td><input type="submit" name="login" value="登陸" onClick="return validateLogin()"/></td> <td><input type="button" value="註冊" onclick="jump2register()"></td> <td><input type="reset" name="rs" value="重置" /></td> </tr> </table> </form> </table> <script language="javascript"> function validateLogin(){ var sUserName = document.Login.username.value ; var sPassword = document.Login.password.value ; if ((sUserName =="") || (sUserName=="Your name")){ alert("請輸入用戶名!"); return false ; } if ((sPassword =="") || (sPassword=="Your password")){ alert("請輸入密碼!"); return false ; } } </script> </body> </html>
在上一次使用官方源下載安裝openvas後,不能用mysql,從新使用中科大源更新,
前端
內存不足,恢復快照java
root@20155203dukx:~# /etc/init.d/mysql start [ ok ] Starting mysql (via systemctl): mysql.service. root@20155203dukx:~# mysql -u root -p Enter password: (初始)p@sswOrd MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ MariaDB [(none)]> use mysql; Database changed MariaDB [mysql]> select user, password, host from user;//查看當前用戶信息 +------+----------+-----------+ | user | password | host | +------+----------+-----------+ | root | | localhost | +------+----------+-----------+ MariaDB [mysql]> UPDATE user SET password=PASSWORD("20155203") WHERE user='root';//更改root的密碼 MariaDB [mysql]> flush privileges;//更新權限 MariaDB [mysql]> create database 20155203dukx; Query OK, 1 row affected (0.01 sec) MariaDB [mysql]> use 20155203dukx; //建立數據庫並打開 MariaDB [20155203dukx]> create table usertest1 (student VARCHAR(20),password VARCHAR(20),identity VARCHAR(20));//新建表格,指明表格包含內容以及每項的長度VARCHAR Query OK, 0 rows affected (0.14 sec) MariaDB [20155203dukx]> insert into usertest1 values('20155203','20155203','student'); Query OK, 1 row affected (0.01 sec) MariaDB [20155203dukx]> select * from usertest1 ; +----------+----------+----------+ | student | password | identity | +----------+----------+----------+ | 20155203 | 20155203 | student | +----------+----------+----------+ 1 row in set (0.00 sec) //插入記錄並查看,若把*替換爲想查找的關鍵字,能夠用於查找與關鍵字有關的記錄。 MariaDB [20155203dukx]> grant select,insert,update,delete on 20155203dukx.* to dukx@localhost identified by "20155203"; //新建用戶,併爲其賦予權限。
不輸入分號,就會一直出現"->「
mysql
<?php $uname=($_POST["username"]); $pwd=($_POST["password"]); $iden=($_POST["identity"]); //自行選擇須要匹配的項目進行添加網頁的表單action使用post,若使用get就改爲get /* echo $uname; */ $query_str="SELECT * FROM usertest1 where username='$uname' and password='$pwd' and identity='$iden';";//從本身的表單裏select /* echo "<br> {$query_str} <br>";*/ $mysqli = new mysqli("127.0.0.1", "dukx", "20155203", "20155203dukx");//b不要使用root通常會失敗,多是由於數據庫的權限問題 /* check connection */ if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } echo "connection ok!"; /* Select queries return a resultset */ if ($result = $mysqli->query($query_str)) { if ($result->num_rows > 0 ){ echo "<br> Wellcome login Mr/Mrs:{$uname} <br> ";//這裏能夠連接本身寫的登錄頁面 } else { echo "<br> login failed!!!! <br> " ; } /* free result set */ $result->close(); } $mysqli->close(); ?>
php測試;查看/etc/password下的內容:
web
添加php後端:登錄成功
sql
' or 1=1#
的時候合成的SQL查詢語句爲select * from lxmtable where username='' or 1=1#' and password=''
if ($result = $mysqli->multi_query($query_str))
';insert into usertest1 values('20155204','5204','student');#
意思是select以後,還要執行insert語句,結果以下:檢索/var/www/html
目錄下的圖片,也就是網頁源碼文件目錄,輸入<img src="圖片文件名稱" />。。。</a>
數據庫
這裏咱們將登錄界面的設計和後臺管理都放在同一個login.php中,經過判斷條件和header函數跳轉不一樣頁面。表單的提交一樣是經過action
<form method = "post" action="<?php echo $_SERVER['PHP_SELF'];?>">
調用自身PHP文件,這裏數據庫表格中的表項我只添加了用戶名和帳號,發帖內容經過函數
file_put_contents('data.txt',"title:".$title.",content:".$content."\n", FILE_APPEND);
寫入data.txt文件中,要對txt文件賦予最高權限,
chmod 777 data.txt
使得對於data.txt文件得讀寫操做可行。編程
登錄以前要肯定是否打開mysql服務,
如下是實現截圖: