Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
- <title>Kasaria - Adopt</title>
- <style type="text/css">
- body {
- text-align:center;
- }
- </style>
- </head>
- <body>
- <?php
- //include stuff
- require("includes/connect.php");
- require("includes/kasaria.php");
- require("includes/members.php");
- if(isset($_GET['action']) && $_GET['action'] == "adopt"){
- if(empty($_POST['color']) || empty($_POST['name']) || empty($_POST['species'])){
- echo 'Please fill out all the fields!';
- exit();
- }
- $newname = preg_replace('/[^a-zA-Z0-9_-\\s]/', '', mysql_real_escape_string($_POST['name']));
- $speciesurl = getURL(mysql_real_escape_string($_POST['species']));
- $user = getID($usernameglobal);
- $result = mysql_query("SELECT * FROM pets WHERE name = '$newname'") or die(mysql_error());
- $numrows = mysql_num_rows($result);
- if( $numrows > 0){
- echo "Sorry, that pet name is taken. Please go back and try again.";
- }
- else {
- $species = mysql_real_escape_string($_POST['species']);
- $color = mysql_real_escape_string($_POST['color']);
- mysql_query("INSERT INTO pets (name, speciesid, color, owner, level, hunger, happiness)
- values ('$newname', '$species', '$color', '$user', '1', '0', '100')") or die(mysql_error());
- echo $newname . ' was sucessfully adopted!<br/><img src="images/' . $speciesurl . $_POST['color'] . '.png"><br/><a href="index.php">Home</a>';
- }
- }
- else {
- $result = mysql_query("SELECT * FROM species WHERE available = '1'") or die(mysql_error());
- $numrows = mysql_num_rows($result);
- if( $numrows > 0){
- while($row = mysql_fetch_array( $result )){
- echo '<img src="images/' . strtolower($row['name']) . 'red.png">
- <img src="images/' . strtolower($row['name']) . 'yellow.png">
- <img src="images/' . strtolower($row['name']) . 'green.png">
- <img src="images/' . strtolower($row['name']) . 'blue.png"><br/>
- <form action="adopt.php?action=adopt" method="post"><input type="radio" name="color" value="red"> Red<br>
- <input type="radio" name="color" value="yellow"> Yellow<br>
- <input type="radio" name="color" value="green"> Green<br/>
- <input type="radio" name="color" value="blue"> Blue<br/>Name:<br/>
- <input type="text" name="name"/><input type="hidden" value="' . $row['id'] . '" name="species">
- <input type="submit" value="Submit" /></form>';
- }}
- else {
- echo 'There are no pets available to adopt!';
- }
- }?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement