Created
November 1, 2014 19:49
-
-
Save anonymous/bc6ca5a82b58827ec733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="css.css"> | |
<title>Halloween</title> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<form method="post"> | |
<input type="text" name="name"> | |
<input type="submit" value="Prediction!"> | |
</form> | |
<!-- <div class="qqq">Ba <?php echo "$nam"; ?>, fsdjfks <br> | |
<?php | |
// echo $qwe[$sg]['prediction']; | |
// echo "<img src=",$qwe[$sg]['url'],">" | |
?> | |
</div> --> | |
<!-- <img src="img/title.jpg"> --> | |
<!-- <input type="text" id="usrText" size="32" /> | |
<input type="button" value="Send" onclick="callServer()" /> | |
<hr> | |
<div id="resultDiv"></div> | |
--> | |
<!-- | |
<form enctype="multipart/form-data" method="post"> | |
<input type="file" name="userfile"> | |
<input type="submit" value="Сохранить"> | |
</form> --> | |
<?php | |
$host = '127.0.0.1'; | |
$user = 'root'; | |
$pass = ''; | |
$link = mysqli_connect($host, $user, $pass,'halloween'); | |
if (mysqli_connect_errno()) { | |
printf("Not work: %s\n", mysqli_connect_error()); | |
exit(); | |
} | |
mysqli_query ($link, "set character_set_client='utf8'"); | |
mysqli_query ($link,"set character_set_results='utf8'"); | |
mysqli_query ($link, "set collation_connection='utf8_general_ci'"); | |
$people = mysqli_query($link, 'SELECT * FROM `people`'); | |
$prediction = mysqli_query($link, 'SELECT * FROM `prediction`'); | |
// name of register | |
$name = $_POST['name']; | |
$nam = $name; | |
$name = mb_strtolower($name); | |
// rendom prediction and image | |
while ($row = $prediction->fetch_assoc()) { | |
$qwe[] = $row; | |
} | |
$sg = array_rand($qwe); | |
$a = mysqli_query($link, 'SELECT * FROM `people` WHERE `name` = "'.$name.'"'); | |
while ($row1 = $a->fetch_assoc()) { | |
$qwe1[] = $row1; | |
} | |
if(!empty($name)) { | |
if($qwe1[0]['name'] == $name) { | |
echo "prediction<br>"; | |
echo $qwe1[0]['prediction_id']; | |
$prediction_id = $qwe1[0]['prediction_id']; | |
} | |
else { | |
$user_name = mysql_real_escape_string($name); // безпека | |
mysqli_query($link, "INSERT INTO `people` (`name`, `prediction_id`) | |
VALUES ('$user_name', $sg);"); | |
$prediction_id = $sg; | |
} | |
} | |
else { | |
echo "Введите имя!! <br>"; | |
} | |
$b = mysqli_query($link, 'SELECT `prediction`.`prediction` | |
FROM `prediction` | |
WHERE `prediction`.`id` = '.$prediction_id); | |
$qwe2 = $b->fetch_assoc(); | |
echo $qwe2['prediction']; | |
// $uploaddir = "z:/home/localhost/www/He/img/"; | |
// // if($_FILES["userfile"]["size"] > 3145728) | |
// // { | |
// // echo("Размер файла превышает три мегабайта"); | |
// // } | |
// $temp=$_FILES['userfile']['name']; | |
// $uploadfile = $uploaddir . $temp; | |
// move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile); | |
// echo $temp; | |
mysqli_close($link); | |
?> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment