Advertisement
Guest User

ssfile

a guest
Jan 30th, 2013
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.88 KB | None | 0 0
  1. <?php
  2.  
  3.   if(isset($_SERVER['REQUEST_METHOD'] === 'POST')){
  4.    
  5.     //post data
  6.     $nick                             = $_POST['nickname'];
  7.     $match                            = $_POST['match'];
  8.     $description                      = $_POST['description'];
  9.     $oras                             = $_POST['oras'];
  10.    
  11.       if(empty($_POST)){
  12.         //post data empty
  13.          print 'Campurile sunt goale, completeaza te rog.';
  14.          die(); //stop script execution
  15.       } else {
  16.        
  17.              $file_path = './script/folder/file.txt';
  18.                        
  19.                         if(!file_exists($file_path)){
  20.                          
  21.                            print 'Fisierul nu exista sau calea spre fisier nu este buna.';
  22.                            die();
  23.                         } else {
  24.  
  25.                         $handle = fopen($file_path, "a");
  26.                         $write  = fwrite($handle, "\n".$match." ".$nickname." ".$oras." ".$description."\n");
  27.                         fclose($handle);
  28.  
  29.                                 if(!$write){
  30.                                  
  31.                                   print 'Eroare de scriere in fisier.';
  32.  
  33.                                 } else {
  34.                                  
  35.                                    header('Location: /xx/replaysend.php');
  36.  
  37.                                 }
  38.                        
  39.                         }
  40.  
  41.       }
  42.  
  43.   }
  44.  
  45. ?>
  46.  
  47.   <form action="" method="post">
  48.  
  49.         <p>Nickname: <input type="text" name="nickname" size="18" /></p>
  50.        
  51.         <p>Match: <input type="text" name="match" size="18"  /></p>
  52.        
  53.         <p>Description: <input type="text" name="description" size="18"  /></p>
  54.        
  55.         <p>Town: <input type="text" name="oras" size="18"  /></p>
  56.        
  57.         <p><input type="submit" name="submit" value="Send" /></p>
  58.   </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement