Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # home.php
- <html>
- <head>
- <title>Guestbook</title>
- </head>
- <body>
- <?php
- include ("msg.txt");
- ?>
- <div id="msg">
- <form action="send.php" method="post">
- Username : <input type="text" id="username" name="username" /><br />
- Inserisci il tuo messaggio : <br /> <textarea name="messaggio" rows="10" cols="30"></textarea><br /> <br />
- <input type="submit" value="Invia messaggio">
- <input type="reset" value="Cancella">
- </form>
- </div>
- </body>
- </html>
- #send.php
- <?php
- $utente=htmlspecialchars($_POST['username']);
- $messaggio=htmlspecialchars($_POST['messaggio']);
- $data= date("d/m/Y H:i:s");
- $msg= "msg.txt";
- if ($utente=="") {
- echo "Inserisci username";
- } elseif ($messaggio=="") {
- echo "Inserisci un messaggio";
- } else {
- $guestbook = fopen($msg,"a");
- $txt='<div id="msg"><font color="red">Messaggio inviato da: '.$utente.'<br /><br />';
- $txt .='Messaggio: '.$messaggio. '<br /><br />';
- $txt .="Messaggio scritto il: ".$data.'</font></div>';
- fwrite($guestbook, $txt);
- fclose($guestbook);
- echo '<a href="http://localhost/home.php">Torna alla home</a>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement