| Subiectul anterior :: Subiectul urmator |
| Autor |
Mesaj |
drbest Administrator

Data inscrierii: 29/Apr/2007 Mesaje: 114
|
Trimis: 18/05/2007 17:38 Titlul subiectului: Cum sa faci un Shout Box |
|
|
Un rudimentar shout box,ai nevoie doar de suport php (fara sql) si un fiser txt unde se vor salva textele.
Copiaza codul intr-un fisier razhello.php si creaza un fisier numit file.txt in acelasi folder.
Uite un exemplu aici: http://www.razexe.3x.ro/razhello.php
Cod sursa:
1.
<html>
2.
<head>
3.
<title> Hello PHP </title>
4.
</head>
5.
<body>
6.
<?php echo '<h1><b>!! my SHOUT BOX !! </h1></b>' ?>
7.
<!-- <a href="razhello.php"> razhello.php </a> <br> -->
8.
<form action="razhello.php" method="post">
9.
<p>nume:<br> <input type="text" maxlength=20 size=50 name="name"><br>
10.
o vorba: <br> <input type="text" maxlength=50 name="comm" size=50>
11.
<input name ="ok" type="submit" value ="OK"></p>
12.
<input name="altceva" type="submit" value ="Fa Ceva..."></p>
13.
</form>
14.
15.
<?php
16.
$nume=$_POST['name'];
17.
$comm=$_POST['comm'];
18.
$altceva=$_POST['altceva'];
19.
$ok=$_POST['ok'];
20.
21.
22.
23.
if (($nume) && ($comm))
24.
{
25.
$fp=fopen("file.txt","a");
26.
$dat=date("l dS of F Y h:i:s A");
27.
//fseek($fp,0,SEEK_SET);
28.
$r=fwrite($fp,"$dat nume: <b>$nume</b> - <i>$comm </i> \r\n");
29.
$r=fclose($fp);
30.
}
31.
//strstr
32.
33.
$fis=file('file.txt');
34.
if (count($fis)>0)
35.
{
36.
echo "<hr>";
37.
for($i=0;$i<count($fis);$i++)
38.
{
39.
echo "$fis[$i] <br>";
40.
//echo "testing...";
41.
}
42.
echo "<hr>";
43.
}
44.
45.
if ((!$nume) && (!$comm) && $ok )
46.
echo "<font color=red><b>trebe sa completezi cele două campuri...</b></font>";
47.
if ($altceva)
48.
echo "<font color=green> <b>ce altceva ? </b> </font>"
49.
50.
?>
51.
</body>
52.
</html> |
|
| Sus |
|
 |
|
|
Nu puteti crea un subiect nou in acest forum Nu puteti raspunde in subiectele acestui forum Nu puteti modifica mesajele proprii din acest forum Nu puteti sterge mesajele proprii din acest forum Nu puteti vota in chestionarele din acest forum
|
Powered by phpBB © 2001, 2002 phpBB Group Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro
|