Guest User

Untitled

a guest
May 15th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. \\\\\\\\\\\\\\\\\Formularz/////////////////////
  2. <!DOCTYPE html>
  3. <head lang="pl">
  4. <meta charset="windows-1250">
  5. </head>
  6. <body>
  7. <form action="cezar_kod.php" method="POST">
  8. Tekst: <input type=text name="tekst">
  9. <br><br>
  10. Podaj klucz: <input type=text name="klucz">
  11. <br><br>
  12.  
  13. <input type=submit value="Szyfruj">
  14. </form>
  15. </body>
  16. </html>
  17. //////////////////KOD PHP\\\\\\\\\\\\
  18. <?php
  19. if (isset($_POST['tekst']))
  20. {
  21. $txt= $_POST['tekst'];
  22. }
  23. $alfabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  24. $kl=$_POST['klucz'];
  25. print_r($_POST);
  26. for ($i=0;$i<strlen($txt);$i++) {
  27.  
  28. $szyfr .= $alfabet[(strpos($alfabet, $txt[$i])+$kl) % strlen($alfabet)];
  29.  
  30. }
  31.  
  32.  
  33. echo $txt.'<br>';
  34. echo $kl.'<br>';
  35. echo $szyfr.'<br>';
  36.  
  37. // wynik: DODPDNRWD
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment