Advertisement
Guest User

dfh

a guest
Oct 26th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. <?php
  2. require('menu.php');
  3. ?>
  4. <br>
  5. <html>
  6.  
  7. <head>
  8. <title>Criar Jogador</title>
  9. </head>
  10.  
  11. <body>
  12. <?php
  13.  
  14. // define variables and set to empty values
  15. $player_id = $nome = $height = $weight = $image_url = $club = $club_image_url = "";
  16.  
  17. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  18. $player_id = test_input($_POST["player_id"]);
  19. $nome = test_input($_POST["nome"]);
  20. $height = test_input($_POST["height"]);
  21. $weight = test_input($_POST["weight"]);
  22. $image_url = test_input($_POST["image_url"]);
  23. $club = test_input($_POST["club"]);
  24. $club_image_url = test_input($_POST["club_image_url"]);
  25. }
  26.  
  27. function test_input($data) {
  28. $data = trim($data);
  29. $data = stripslashes($data);
  30. $data = htmlspecialchars($data);
  31. return $data;
  32. }
  33. ?>
  34.  
  35. <h2>Adiciona um jogador:</h2>
  36.  
  37. <form method = "post" action = "/php/php_form_introduction.htm">
  38. <table>
  39. <tr>
  40. <td>Player_id:</td>
  41. <td><input type = "text" name = "player_id"></td>
  42. </tr>
  43.  
  44. <tr>
  45. <td>Nome:</td>
  46. <td><input type = "text" name = "nome"></td>
  47. </tr>
  48.  
  49. <tr>
  50. <td>Height:</td>
  51. <td><input type = "text" name = "height"></td>
  52. </tr>
  53.  
  54. <tr>
  55. <td>Weight</td>
  56. <td><input type = "text" name = "height"></td>
  57. </tr>
  58.  
  59. <tr>
  60. <td>Clube:</td>
  61. <td><input type = "text" name = "height"></td>
  62. </tr>
  63.  
  64.  
  65. </table>
  66. </form>
  67.  
  68. <?php
  69.  
  70. if(isset($_FILES['image'])){
  71. $errors= array();
  72. $file_name = $_FILES['image']['name'];
  73. $file_size =$_FILES['image']['size'];
  74. $file_tmp =$_FILES['image']['tmp_name'];
  75. $file_type=$_FILES['image']['type'];
  76. $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
  77.  
  78. $expensions= array("jpeg","jpg","png");
  79.  
  80. if(in_array($file_ext,$expensions)=== false){
  81. $errors[]="extension not allowed, please choose a JPEG or PNG file.";
  82. }
  83.  
  84. if($file_size > 2097152){
  85. $errors[]='File size must be excately 2 MB';
  86. }
  87.  
  88. if(empty($errors)==true){
  89. move_uploaded_file($file_tmp,"images/".$file_name);
  90. echo "Success";
  91. }else{
  92. print_r($errors);
  93. }
  94. }
  95. ?>
  96. <html>
  97. <body>
  98.  
  99.  
  100. <td>Imagem do jogador:</td>
  101. <form action="" method="POST" enctype="multipart/form-data">
  102. <input type="file" name="image" />
  103.  
  104. </form>
  105.  
  106. <td>Logo do clube:</td>
  107. <form action="" method="POST" enctype="multipart/form-data">
  108. <input type="file" name="image" />
  109.  
  110. </form>
  111.  
  112. <input type="submit"/>
  113.  
  114.  
  115. </body>
  116. </html>
  117.  
  118.  
  119.  
  120. </body>
  121. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement