<?php
$db_host = 'localhost';
$db_name = 'rgraph_example';
$db_username = 'user';
$db_password = 'password';
$connect_to_db = mysql_connect($db_host, $db_username, $db_password);
if (!$connect_to_db) {
die("Could not connect: " . mysql_error());
}
if (!mysql_select_db($db_name, $connect_to_db)) {
die("Could not select DB: " . mysql_error());
}
$sql = "SELECT `daily_statistics`.`Values` , `daily_statistics`.`Id` , `Humidity`.`Humidity` , `Temp`.`Value` ".
"FROM daily_statistics LEFT JOIN `rgraph_example`.`Humidity` ON `daily_statistics`.`Id` = `Humidity`.`Id` ".
"LEFT JOIN `rgraph_example`.`Temp` ON `daily_statistics`.`Id` = `Temp`.`Id` LIMIT 0 , 30";
$result = mysql_query($sql);
if (!$result) {
die(mysql_error());
}
$data = array();
while ($row = mysql_fetch_array($qr_result)) {
$data[] = $row;
}
?>
<table border="1">
<thead>
<tr>
<th>id</th>
<th>Values</th>
<th>Humidity</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php foreach ($data as $item):?>
<tr>
<td><?php echo $item['Id'] ?></td>
<td><?php echo $item['Values'] ?></td>
<td><?php echo $item['Humidity'] ?></td>
<td><?php echo $item['Value'] ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
$(function() {
$("#form").on("submit", function(event) {
event.preventDefault();
var message = $("#message").val();
$.post("mail.php", {message: message}, function(response) {
$("#aj").text(response);
});
return false;
});
});
<?php
$message = $_POST['message'];
if (mail("мой_имэил", "Тема", "Сообщение: " . $message)) {
return "Сообщение отправлено";
} else {
return "Что ещё за?";
}
?>
<?php
if (isset($_GET['action']) && ($_GET['action'] == 'logout') {
restLogout();
}
?>
<header>
<div class="wrapper">
<nav>
<p>Restaurant Tuscany</p>
<ul>
<li><a href="?page=2">Menu</a></li>
<li><a href="?page=3">Gallery</a></li>
<li><a href="?page=4">Contact</a></li>
<?php if (isset($_SESSION['username']) && count($userRows)): ?>
<li><a href='?action=logout'>Logud</a></li>
<?php else: ?>
<li><a href="?page=5">Login</a></li>
<?php endif; ?>
</ul><!-- ul ends here -->
<div class="clear"></div>
</nav><!-- nav ends here -->
<h1><br>Why travel to Italy<br>to taste the local<br>traditions?</h1>
<div class="circle">
<p><br>Get your<br> Tuscany<br> daily special<br> here</p>
</div><!-- circle ends here -->
</div><!-- wrapper ends here -->
</header><!-- header ends here -->
<?php
//Virker med Admin
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = hash('sha256', $_POST['password']);
restLogin($username, $password);
}
?>
<?php if (isset($_SESSION['username'])): ?>
<script>window.location.replace('?page=home');</script>
<?php else: ?>
<div class="login">
<div class="loginWrapper">
<div id="login">
<div id="triangle"></div>
<h1>Log in</h1>
<form action="" method="POST">
<input type="text" name="username" placeholder="Username" />
<?php if($_GET['error'] == 2): ?>
Wrong Username
<?php endif; ?>
<input type="password" name="password" placeholder="Password" />
<?php if($_GET['error'] == 3): ?>
Wrong Password
<?php endif; ?>
<input type="submit" name="submit" value="Login" />
</form>
<?php if($_GET['error'] == 1): ?>
All should be field out
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php
function restLogin($username, $password) {
global $objCon;
if ($username != '' && $password != '') {
$checkUser = $objCon->query("SELECT username FROM rest_user WHERE username = '$username' LIMIT 1");
$checkAdmin = $objCon->query("SELECT username, password, userType FROM rest_user WHERE ".
"username = '$username' AND password = '$password' AND userType = 1");
$checkPass = $objCon->query("SELECT username, password FROM rest_user WHERE username = ".
"'$username' AND password = '$password' LIMIT 1");
if (mysqli_num_rows($checkUser) != 1) {
header('Location: ?page=5&error=2');
} elseif (mysqli_num_rows($checkPass) != 1) {
header('Location: ?page=5&error=3');
} elseif (mysqli_num_rows($checkAdmin) >= 1) {
$_SESSION['username'] = $username;
header('Location: ?page=100');
} else {
$_SESSION['username'] = $username;
header('Location: ?page=200');
}
} else {
header('Location: ?page=5&error=1');
}
}
function restLogout() {
unset($_SESSION['username']);
header('Location: ?page=home');
}
?>
<span class="breadcrumbs">
<span class="left">
<span class="container">
<? foreach ($this->shopNav as $key => $page): ?>
<? if ($key < count($this->shopNav) - 1): ?>
<a href="<?= $page['url'] ?>"><?= $page['label'] ?></a> /
<? elseif: ?>
<?= $page['label'] ?>
<? endif; ?>
<? endforeach; ?>
</span>
</span>
<span class="right"></span>
</span>
function wf_custom_option_menu() {
$items = array(
'content/spasibo-za-zayavku' => array(
'title' => '',
'page callback' => 'wf_custom_option_page',
'access callback' => true,
)
);
return $items;
}
function wf_custom_option_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'webform_client_form_44')
$form['#submit'][] = 'wf_custom_option_submit';
}
}
function wf_custom_option_submit($form, &$form_state) {
//$_SESSION['name'] = $form_state['values']['submitted']['name'];
$form_state['redirect'] = array(
'content/spasibo-za-zayavku',
array(
'query' => array(
'imya_i_otchestvo' => $_POST['submitted']['imya_i_otchestvo'],
),
),
);
//debug($form_state['values']);
}
function wf_custom_option_page() {
if (!isset($_GET['imya_i_otchestvo'])) {
drupal_goto('<front>');
} else {
$output = '<div id = "senks"><div class = "black"><a>' . $_GET['imya_i_otchestvo'] .
', cпасибо за заявку.</a></div><div class = "red"><a>Менеджер свяжется с вами через 30 минут!</a></div></div>';
return $output;
}
}
function Comlib() {
this.getMessage = function(cb) {
$.get("get_messages.php", function(resp) {
cb && cb(resp);
});
}
}
var comlib = new Comlib();
comlib.getMessage(function(num) {
console.log(num) // здесь уже можно работать с num
});
<?php
header('Content-Type: text/html; charset=utf-8');
$recipient = 'mail@gmail.com';
$title = 'Cообщение с сайта';
$headers = 'Content-type: text; charset="utf-8"';
if (isset($_POST['ok'])) {
$fio = isset($_POST['fio']) ? $_POST['fio'] : '(фио не введено)';
$email = isset($_POST['email']) ? $_POST['email'] : '(email не введен)';
$tel = isset($_POST['tel']) ? $_POST['tel'] : '(телефон не введен)';
$text = isset($_POST['text']) ? $_POST['text'] : '(коментарий не введен)';
$deadline = isset($_POST['deadline']) ? $_POST['deadline'] : '(дедлайн не введен)';
$message = $text . "\n" . $email . "\n" . $tel . "\n" . $fio . "\n" . $deadline;
if (mail($recipient, $title, $message, $headers)) {
echo "Ваше сообщение отправлено.";
} else {
echo "Сообщение НЕ отправлено, что то пошло не так :(";
}
}