PHP 0
From Ilianko
Contents
HTML форма
<body> <div style="position:relative; top:100px; left:100px"> <form method="post" name="comment" action="" > <table> <tr> <td>Email: </td> <td><input name="email" type="text" size="20" maxlength="199" value="" /></td></tr> <tr> <td>Име </td> <td><input name="name" type="text" size="20" maxlength="60" value="" /></td></tr> <tr> <td>Коментар: </td><td><textarea name="comment" cols="43" rows="4"></textarea></td></tr> <tr> <td colspan="2" align="center"><input type="submit" name="submit" id="ss" value="Изпрати"> </td></tr></table> </form> </div> </body> </html>
PHP вградени промеливи
<html>
<body>
<?php
print "POST ->";
print_r( $_POST);
print "GET ->";
print_r($_GET);
print "SERVER ->";
print_r($_SERVER);
print "SESSION ->";
print_r($_SESSION);
?>
<div style="position:relative; top:100px; left:100px">
<form method="post" name="comment" action="" >
<table>
<tr>
<td>Email: </td>
<td><input name="email" type="text" size="20" maxlength="199" value="" /></td></tr>
<tr>
<td>Име </td>
<td><input name="name" type="text" size="20" maxlength="60" value="" /></td></tr>
<tr>
<td>Коментар: </td><td><textarea name="comment" cols="43" rows="4"></textarea></td></tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" id="ss" value="Изпрати">
</td></tr></table>
</form>
</div>
</body>
</html>
Запис във файл
<html>
<body>
<?php
print "POST ->";
print_r( $_POST);
print "GET ->";
print_r($_GET);
if (isset($_POST['submit']))
{
$fd = fopen('../user/data.txt' , 'a');
fwrite ( $fd , $_POST['email']."\n");
fwrite ( $fd , $_POST['email']."\n");
fwrite ( $fd , $_POST['comment']."\n");
fclose($fd);
}
?>
<div style="position:relative; top:100px; left:100px">
<form method="post" name="comment" action="" >
<table>
<tr>
<td>Email: </td>
<td><input name="email" type="text" size="20" maxlength="199" value="" /></td></tr>
<tr>
<td>Име </td>
<td><input name="name" type="text" size="20" maxlength="60" value="" /></td></tr>
<tr>
<td>Коментар: </td><td><textarea name="comment" cols="43" rows="4"></textarea></td></tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" id="ss" value="Изпрати">
</td></tr></table>
</form>
</div>
</body>
</html>
Качване на файл
<html> <body> <?php print "POST ->"; print_r( $_POST); print "FILES ->"; print_r($_FILES); if (isset($_POST['submit'])) { $fd = fopen('../user/data.txt' , 'a'); fwrite ( $fd , $_POST['email']."\n"); fwrite ( $fd , $_POST['email']."\n"); fwrite ( $fd , $_POST['comment']."\n"); fclose($fd); } ?> <div style="position:relative; top:100px; left:100px"> <form method="post" name="comment" enctype="multipart/form-data" action="" > <table> <tr> <td>Email: </td> <td><input name="email" type="text" size="20" maxlength="199" value="" /></td></tr> <tr> <td>Име </td> <td><input name="name" type="text" size="20" maxlength="60" value="" /></td></tr> <tr> <td>Коментар: </td><td><textarea name="comment" cols="43" rows="4"></textarea></td></tr> <tr> <tr> <td>Картинка: </td><td><input type="file" name="image" title="Select Image"></td></tr> <tr> <td colspan="2" align="center"><input type="submit" name="submit" id="ss" value="Изпрати"> </td></tr></table> </form> </div> </body> </html>
Запис на качен файл
<html> <body> <?php print "POST ->"; print_r( $_POST); print "FILES ->"; print_r($_FILES); if (isset($_POST['submit'])) { if($_FILES["image"]['name'] ) { $tempFileName = $_FILES['image']['tmp_name']; // temporary file at server side copy ( $_FILES['image']['tmp_name'], '../user/'.$_FILES["image"]['name'] ); } } ?> <div style="position:relative; top:100px; left:100px"> <form method="post" name="comment" enctype="multipart/form-data" action="" > <table> <tr> <td>Email: </td> <td><input name="email" type="text" size="20" maxlength="199" value="" /></td></tr> <tr> <td>Име </td> <td><input name="name" type="text" size="20" maxlength="60" value="" /></td></tr> <tr> <td>Коментар: </td><td><textarea name="comment" cols="43" rows="4"></textarea></td></tr> <tr> <tr> <td>Картинка: </td><td><input type="file" name="image" title="Select Image"></td></tr> <tr> <td colspan="2" align="center"><input type="submit" name="submit" id="ss" value="Изпрати"> </td></tr></table> </form> </div> </body> </html>