<form action="" method="post">
<input type="number" required name="min">
<input type="number" required name="max">
<input type="submit" name="submit">
<p>
<?php
if (isset($_POST['submit'])) {
$min = intval($_POST['min']);
$max = intval($_POST['max']);
$n = rand($min , $max);
echo $n;
}
?>
</p>
$router = $di->getRouter(FALSE);
//$router = Phalcon\Mvc\Router(FALSE);
...
...
$router->notFound([
'controller' => 'index',
'action' => 'route404'
]);
...
class IndexController extends ControllerBase
{
public function route404Action()
{
$this->view->disable();
$this->response->setRawHeader('HTTP/1.1 404 Not Found');
$this->response->setContent('<b>404, bratishka :(</b>');
$this->response->send();
}
}
$email = $_POST['email']; //не забудь фильтрацию потом сделать.
$post = $pdo->prepare('SELECT * FROM subscribe WHERE email = ?');
$post->execute($email);
$game = $post->fetch();
if ($game->email != $email){
/*
$fields = array("email");
$sql = "INSERT INTO subscribe SET ".pdoSet($fields,$values);
*/
$stm = $pdo->prepare($sql);
$stm->execute($values);
echo "Вы успешно подписались";
}
else{
echo "email уже в базе данных";
}
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
if(!$email){echo "емейл указан неверно";}
$post = $pdo->prepare('SELECT * FROM subscribe WHERE email = :email');
$post->bindParam(':email', $email, PDO::PARAM_STR);
$post->execute();
$game = $post->fetch();
if ($game->email != $email)
{
$sub= $pdo->prepare('INSERT INTO subscribe SET email = :email');
$sub->bindParam(':email', $email, PDO::PARAM_STR);
if($sub->execute())
{
echo "Вы успешно подписались";
}else{
echo "Не могу сохранить подписку.";
}
}else{
echo "email уже в базе данных";
}
$cords = $_POST['cords'];
include_once("DataBase.php");
$db = new DataBase();
$long_st = $cords[0];
$lat_st = $cords[1];
$db->dbQuery("INSERT INTO `point`(`long`, `lat`)
VALUES (' ".$long_st." ', ' ".$lat_st." ')");
$select = $db->dbQuery("SELECT * FROM `point` WHERE long = '0' AND lat ='0' ");
if (mysql_num_rows($select) == 0)
{
exit("Ничего не нашёл");
}
$ret = array();
while ($row = mysql_fetch_assoc($select))
{
$ret[] = $row;
}
public function dbQuery($sql)
{
$this->dbInit();
$res = mysql_query($sql);
if(!$res)
exit("Помилка - ".mysql_error().", ".$res);
return $res;
}
<?php
include "config.php";
$id = (isset($_GET['id']) && is_numeric($_GET['id'])) ? (int) $_GET['id'] : 0;
mysql_select_db($dbname) or die('Нет базы');
$res = mysql_query('SELECT * FROM `news` WHERE `id` = '.$id.' ');
while ($row = mysql_fetch_array($res, MYSQL_ASSOC))
{
echo '<div>' .$row["text"]. '</div>';
}
?>
<a href="news.php?id=1">Подробнее</a>