Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ($_SESSION['username'] != 'admin') {
- echo "<img src='upload/abel.gif' /><h1>This is not the page you are looking for <a href='index.php'>home</a></h1>";
- echo "<meta http-equiv='refresh' content='1; url=index.php'>";
- }
- else {
- $pdo = new PDO("mysql:host=localhost;dbname=fantapc", 'fpcroot', '');
- function image_upload($name, $tmpname) {
- move_uploaded_file($tmpname, "upload/" . $name);
- // echo "Stored in: " . "upload/" . filename;
- return "upload/" . $name;
- }
- if(isset($_POST['addcard'])) {
- $cardname = $_POST['card_input'];
- $rarity = $_POST['rarity_input'];
- $image_front = image_upload($_FILES['image_front']['name'], $_FILES['image_front']['tmpname']);
- $image_back = image_upload($_FILES['image_back']['name'], $_FILES['image_back']['tmpname']);
- $image_avatar = image_upload($_FILES['image_avatar']['name'], $_FILES['image_avatar']['tmpname']);
- $image_sprite = image_upload($_FILES['image_sprite']['name'], $_FILES['image_sprite']['tmpname']);
- $query = $pdo->prepare("INSERT INTO cards (name,rarity,img_front,img_back,img_avatar,img_sprite) VALUES (:name,:rarity,:img_front,:img_back,:img_avatar,:img_sprite)");
- $query->bindValue(":name", $cardname, PDO::PARAM_STR);
- $query->bindValue(":rarity", $rarity, PDO::PARAM_STR);
- $query->bindValue(":img_front", $image_front, PDO::PARAM_STR);
- $query->bindValue(":img_back", $image_back, PDO::PARAM_STR);
- $query->bindValue(":img_avatar", $image_avatar, PDO::PARAM_STR);
- $query->bindValue(":img_sprite", $image_sprite, PDO::PARAM_STR);
- $query->execute();
- } else { echo "no files"; }
- ?>
- <h1>Add cards</h1>
- <form action="index.php?page=addcards" method="post" enctype="multipart/form-data">
- <table>
- <tr>
- <td>cardname: </td><td> <input type="text" name="card_input"></td></tr>
- <tr>
- <td>rarity: </td><td> <select name="rarity_input">
- <option value="1">1 star</option>
- <option value="2">2 star</option>
- <option value="3">3 star</option>
- <option value="4">4 star</option>
- <option value="5">5 star</option>
- <option value="6">6 star</option>
- <option value="7">7 star</option>
- </select></td></tr>
- <tr>
- <td>card front: </td><td><input type="file" name="image_front" id="file"></td></tr>
- <tr>
- <td>card back: </td><td><input type="file" name="image_back" id="file"></td></tr>
- <tr>
- <td>avatar: </td><td><input type="file" name="image_avatar" id="file"></td></tr>
- <tr>
- <td>gif sprite: </td><td><input type="file" name="image_sprite" id="file"></td></tr>
- <tr>
- <td></td><td>
- <input type="hidden" name="addcard" value="1">
- <input type="submit" value="add card!"></td>
- </tr></table></form>
- <? } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement