Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('menu.php');
- ?>
- <br>
- <html>
- <head>
- <title>Criar Jogador</title>
- </head>
- <body>
- <?php
- // define variables and set to empty values
- $player_id = $nome = $height = $weight = $image_url = $club = $club_image_url = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $player_id = test_input($_POST["player_id"]);
- $nome = test_input($_POST["nome"]);
- $height = test_input($_POST["height"]);
- $weight = test_input($_POST["weight"]);
- $image_url = test_input($_POST["image_url"]);
- $club = test_input($_POST["club"]);
- $club_image_url = test_input($_POST["club_image_url"]);
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
- <h2>Adiciona um jogador:</h2>
- <form method = "post" action = "/php/php_form_introduction.htm">
- <table>
- <tr>
- <td>Player_id:</td>
- <td><input type = "text" name = "player_id"></td>
- </tr>
- <tr>
- <td>Nome:</td>
- <td><input type = "text" name = "nome"></td>
- </tr>
- <tr>
- <td>Height:</td>
- <td><input type = "text" name = "height"></td>
- </tr>
- <tr>
- <td>Weight</td>
- <td><input type = "text" name = "height"></td>
- </tr>
- <tr>
- <td>Clube:</td>
- <td><input type = "text" name = "height"></td>
- </tr>
- </table>
- </form>
- <?php
- if(isset($_FILES['image'])){
- $errors= array();
- $file_name = $_FILES['image']['name'];
- $file_size =$_FILES['image']['size'];
- $file_tmp =$_FILES['image']['tmp_name'];
- $file_type=$_FILES['image']['type'];
- $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
- $expensions= array("jpeg","jpg","png");
- if(in_array($file_ext,$expensions)=== false){
- $errors[]="extension not allowed, please choose a JPEG or PNG file.";
- }
- if($file_size > 2097152){
- $errors[]='File size must be excately 2 MB';
- }
- if(empty($errors)==true){
- move_uploaded_file($file_tmp,"images/".$file_name);
- echo "Success";
- }else{
- print_r($errors);
- }
- }
- ?>
- <html>
- <body>
- <td>Imagem do jogador:</td>
- <form action="" method="POST" enctype="multipart/form-data">
- <input type="file" name="image" />
- </form>
- <td>Logo do clube:</td>
- <form action="" method="POST" enctype="multipart/form-data">
- <input type="file" name="image" />
- </form>
- <input type="submit"/>
- </body>
- </html>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement