-
-
Save mykhas/97a4697d7826fc9c340b 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> | |
<?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); | |
if(empty($name) && isset($_POST['name'])) { | |
echo "Введите имя!! <br>"; | |
} | |
// 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; | |
} | |
$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