Advertisement
Guest User

Guestbook - PHP & HTML

a guest
Jul 14th, 2011
1,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. # home.php
  2.  
  3. <html>
  4. <head>
  5. <title>Guestbook</title>
  6. </head>
  7.  
  8. <body>
  9. <?php
  10. include ("msg.txt");
  11. ?>
  12.  
  13. <div id="msg">
  14. <form action="send.php" method="post">
  15. Username : <input type="text" id="username" name="username" /><br />
  16. Inserisci il tuo messaggio : <br /> <textarea name="messaggio" rows="10" cols="30"></textarea><br /> <br />
  17. <input type="submit" value="Invia messaggio">
  18. <input type="reset" value="Cancella">
  19.  
  20.  
  21. </form>
  22. </div>
  23. </body>
  24.  
  25. </html>
  26.  
  27.  
  28.  
  29. #send.php
  30.  
  31. <?php
  32. $utente=htmlspecialchars($_POST['username']);
  33. $messaggio=htmlspecialchars($_POST['messaggio']);
  34. $data= date("d/m/Y H:i:s");
  35. $msg= "msg.txt";
  36.  
  37. if ($utente=="") {
  38. echo "Inserisci username";
  39. } elseif ($messaggio=="") {
  40. echo "Inserisci un messaggio";
  41. } else {
  42. $guestbook = fopen($msg,"a");
  43. $txt='<div id="msg"><font color="red">Messaggio inviato da: '.$utente.'<br /><br />';
  44. $txt .='Messaggio: '.$messaggio. '<br /><br />';
  45. $txt .="Messaggio scritto il: ".$data.'</font></div>';
  46. fwrite($guestbook, $txt);
  47. fclose($guestbook);
  48. echo '<a href="http://localhost/home.php">Torna alla home</a>';
  49.  
  50. }
  51.  
  52.  
  53.  
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement