Guest User

Untitled

a guest
Apr 25th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <?php
  2. $myFile = "config.txt";
  3. $fh = fopen($myFile, 'w') or die("can't open file");
  4. ?>
  5. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
  6. <p><input type="text" name="username" /> Username</p>
  7. <p><input type="text" name="password" /> Password</p>
  8. <p><input type="text" name="address" /> Connection Address</p>
  9. <p><input type="text" name="port" /> Port Number</p>
  10. <p><input type="text" name="database" /> Database</p>
  11. <?
  12. $port = $_POST['port'];
  13. fwrite($fh, $port);
  14. $user = $_POST['username'];
  15. fwrite($fh, $user);
  16. $pass = $_POST['password'];
  17. fwrite($fh, $pass);
  18. $address = $_POST['address'];
  19. fwrite($fh, $address);
  20. $data1 = $_POST['database'];
  21. $data = "$data1";
  22. fwrite($fh, $data);
  23. fclose($fh);
  24. if(isset($_POST['submit'])) {
  25.  
  26. if(!empty($_POST['port']) && !empty($_POST['password']) && !empty($_POST['username']) && !empty($_POST['database']) && !empty($_POST['address'])) {
  27. $accept = "Thank you for contacting me.";
  28.  
  29. } else {
  30.  
  31. $error = "Please fill out the entire form.";
  32.  
  33. }
  34.  
  35. }
  36. ?>
  37. <?php if(!empty($error)) echo '<div class="error">'.$error.'</div>'; ?>
  38. <?php if(!empty($accept)) echo '<div class="accept">'.$accept.'</div>'; ?>
  39.  
  40. <?php
  41. echo "Write yes to prove it!"
  42. ?>
  43. <p><input type="submit" name="submit" value="Send" class="button" /></p>
  44. </form>
  45. ?>
Add Comment
Please, Sign In to add comment