PHP-表单的读写,File文件的操作等---ShinePans
实践一:
表单的操作:
wlcome_page.php
<?php include("menu1.php"); ?>
welcome_info.php:
<font color="pink"><h1 id="Welcome-php-echo-POST-name-br-h">Welcome! <?php echo $_POST["name"]?> <br> <h1></h1> </h1></font> <font color="yellow"><h2 id="You-are-php-echo-POST-age-years-old"> You are <?php echo $_POST["age"] ?> years old.</h2></font> <font color="green"><h2 id="Your-Address-is-php-echo-POST-address">Your Address is <?php echo $_POST["address"]; ?> .</h2></font><br> <font color="blue"><h2 id="Your-Phone-number-is-php-echo-POST-phone-number">Your Phone number is <?php echo $_POST["phone_number"]; ?> .</h2></font><br>
menu1.php:
<a href="http://localhost:8080/php_test/wlcome_page.php">Home</a>| <a href="http://localhsot:8080/php_test/about1.php">About Us</a>| <a href="http://localhost:8080/php_test/contact.php">Contact Us</a>
表单显示效果,填写信息:
实践二
文件的上传,文件的读取:
open_close_file_test.php:
<?php $num_of_char=0; $file=fopen("test_files1.txt","r+"); //$file1=fopen("test_files2.txt","r") or exit("unable to open file!"); //fclose($file1); /* 下面的代码是逐行读取文件的代码, feof:判定是否读到了文件结束标志 fgets:逐行读取文件 */ while(!feof($file)) { echo fgets($file)."<br/>"; } /* 字数判定; */ $file1=fopen("test_files1.txt","r"); while(!feof($file1)) { if(fgetc($file1)!=' ') $num_of_char++; } echo "The test_files1.txt have the number of ".$num_of_char." chars"; ?>
upload_file.php
<?php if($_FILES["file"]["error"]>0) { echo "Error:".$_FILES["files"]["error"]."<br>"; } else { echo "Upload:".$_FILES["file"]["name"]."<br>"; echo "Type:".$_FILES["file"]["type"]."<br>"; echo "Size:".($_FILES["file"]["size"]/1024)."kb<br>"; echo "Stored in:".$_FILES["file"]["tmp_name"]; } ?>
效果显示:
上传后服务器返回的信息:
至此,表单的信息获取,文件的上传实践至此.

phpIdentifiesauser'ssessionSessionSessionCookiesAndSessionId.1)whiwsession_start()被稱為,phpgeneratesainiquesesesessionIdStoredInacookInAcookInAcienamedInAcienamedphpsessIdontheuser'sbrowser'sbrowser.2)thisIdallowSphptpptpptpptpptpptpptpptoretoreteretrieetrieetrieetrieetrieetrieetreetrieetrieetrieetrieetremthafromtheserver。

PHP會話的安全可以通過以下措施實現:1.使用session_regenerate_id()在用戶登錄或重要操作時重新生成會話ID。 2.通過HTTPS協議加密傳輸會話ID。 3.使用session_save_path()指定安全目錄存儲會話數據,並正確設置權限。

phpsessionFilesArestoredIntheDirectorySpecifiedBysession.save_path,通常是/tmponunix-likesystemsorc:\ windows \ windows \ temponwindows.tocustomizethis:tocustomizEthis:1)useession_save_save_save_path_path()

ToretrievedatafromaPHPsession,startthesessionwithsession_start()andaccessvariablesinthe$_SESSIONarray.Forexample:1)Startthesession:session_start().2)Retrievedata:$username=$_SESSION['username'];echo"Welcome,".$username;.Sessionsareserver-si

利用會話構建高效購物車系統的步驟包括:1)理解會話的定義與作用,會話是服務器端的存儲機制,用於跨請求維護用戶狀態;2)實現基本的會話管理,如添加商品到購物車;3)擴展到高級用法,支持商品數量管理和刪除;4)優化性能和安全性,通過持久化會話數據和使用安全的會話標識符。

本文討論了PHP中的crypt()和password_hash()的差異,以進行密碼哈希,重點介紹其實施,安全性和對現代Web應用程序的適用性。

文章討論了通過輸入驗證,輸出編碼以及使用OWASP ESAPI和HTML淨化器之類的工具來防止PHP中的跨站點腳本(XSS)。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Dreamweaver CS6
視覺化網頁開發工具

記事本++7.3.1
好用且免費的程式碼編輯器

Atom編輯器mac版下載
最受歡迎的的開源編輯器

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器