index.html -------- |
<html> |
<title>by kris</title> |
<body> |
<form action= "1.php" method= "GET" > |
用户名:<input type= "text" name= "name" > |
密码:<input type= "text" name= "pass" > |
<input type= "submit" value= "提交" ><input type= "reset" value= "重写" > |
</form> |
</body> |
</html> |
1.php -------- |
<?php |
$n4me = $_GET [ 'name' ]; |
$p4ss = $_GET [ 'pass' ]; |
$t3xt = fopen ( 'name.txt' , w); |
$t3xt2 = fopen ( 'pass.txt' , w); |
echo "name写入了:" .fwrite( $t3xt , $n4me ). "个字符" . "<p>" ; |
echo "pass写入了:" .fwrite( $t3xt2 , $p4ss ). "个字符" . "<p>" ; |
fclose( $t3xt2 ); |
fclose( $t3xt ); |
if ( is_file ( 'name.txt' )|| is_file ( 'pass.txt' ) ) { |
echo "<h2>" . '两个文件写入成功' . "<p>" ; |
$du = fopen ( 'name.txt' , r); |
$du2 = fopen ( 'name.txt' , r); |
echo "<p><h2>用户名:" . fgets ( $du ). "<br>密码:" . fgets ( $du2 ); |
//fclose($du); |
} |
?> |