Last active
March 2, 2017 13:18
-
-
Save raplas/2fc9891bd918ec7a22960886997d2d1e to your computer and use it in GitHub Desktop.
form.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>form1</title> | |
</head> | |
<body> | |
<form action="form0302.php" method="post"> | |
番号:<br /> | |
<input type="text" name="index" size="30" ><br /> | |
名前:<br /> | |
<input type="text" name="name" size="30" ><br /> | |
自己紹介文:<br /> | |
<input type="text" name="introduce" size="30" ><br /> | |
<input type="submit" value="登録する" ><br/> | |
<table border='1'> | |
<tr><th>id</th><th>名前</th><th>自己紹介</th></tr> | |
<?php | |
require_once 'Introduct0332.php'; | |
if (isset($_POST["index"]) && isset($_POST["name"]) && isset($_POST["introduce"])){ | |
$x=$_POST['index']; $y=$_POST['name']; $z=$_POST['introduce']; | |
$object=new Introduct(); | |
$object->regist_file($x,$y,$z); | |
$object->showAll(); | |
$size= sizeof(file("file.csv")); | |
echo "<tr>"; | |
for($i = 0; $i < count($array); ++$i ){ | |
$elem = nl2br(mb_convert_encoding($array[$i], 'UTF-8')); | |
$elem = $elem === "" ? " " : $elem; | |
echo("<td>".$elem."</td>"); | |
} | |
echo "</tr>"; | |
} | |
?> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Introduct { | |
public function regist_file($x,$y,$z){ | |
$fp = fopen("file.csv", "a"); | |
fwrite($fp, "$x,"); | |
fwrite($fp, "$y,"); | |
fwrite($fp, "$z \n"); | |
fclose($fp ); | |
} | |
public function showAll(){ | |
$fp = fopen("file.csv", "r"); | |
while ($line = fgets($fp)) { | |
echo "$line \n"; | |
} | |
$size= sizeof(file("file.csv")); | |
while (($array = fgetcsv($fp)) !== FALSE) { | |
if(!array_diff($array, array(''))){ | |
continue; | |
} | |
fclose($fp); | |
} | |
} | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment