Skip to content

Instantly share code, notes, and snippets.

@brun0xff
Last active February 13, 2017 19:48
Show Gist options
  • Save brun0xff/b27f90d21b864b6062f49bfe16245c12 to your computer and use it in GitHub Desktop.
Save brun0xff/b27f90d21b864b6062f49bfe16245c12 to your computer and use it in GitHub Desktop.
<?php
if(isset($_COOKIE["count"])) {
$count = $_COOKIE["count"];
$count++;
setcookie("count", $count, time() + 600);
} else {
$count = 0;
setcookie("count", $count, time() + 600);
}
?> <html>
<head>
<title>Uso de Cookies</title>
</head>
<body>
<h1><?php echo $count; ?></h1>
</body>
</html>
<?php
$login = $_POST["login"];
$senha = $_POST["senha"];
try{
$conn = new PDO("mysql:host=localhost;dbname=teste", $login, $senha);
$conn-exec("set names utf8");
$stmt = $conn->prepare('SELECT * FROM user WHERE login=:login');
$stmt->bindValue(":login" , $_POST['login']);
$stmt->execute();
$stmt = $conn->prepare('SELECT username FROM user WHERE id_curso=1);
$stmt->execute();
while($row = #stmt->fetch(PDO::FETCH_OBJ)){
print(row->username . "<br />");
}
} catch(PDOException $e){
echo $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment