1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
| <?php
session_start();
$bdd = new PDO("mysql:host=localhost;dbname=calendar;charset=utf8", "root", "");
$get = $bdd->query("SELECT * FROM races order by raceday asc");
if(isset($_GET['q']) AND !empty($_GET['q'])) {
$q = htmlspecialchars($_GET['q']);
$q = $_GET['q'];
$q = trim($q); //pour supprimer les espaces dans la requête de l'internaute
$q = strip_tags($q); //pour supprimer les balises html dans la requête
$get = $bdd->query('SELECT racename, showracedate, town, country, country_tag FROM races WHERE racename LIKE "%'.$q.'%" ORDER BY id ASC');
if($get->rowCount() == 0) {
$get = $bdd->query('SELECT racename, showracedate, town, country, country_tag FROM races WHERE CONCAT(racename, showracedate, town, country, country_tag) LIKE "%'.$q.'%" ORDER BY id ASC');
}
}
if(isset($_POST['signin']))
{
$mailin = htmlspecialchars($_POST['mailin']);
$passwordin = $_POST['passwordin'];
if(!empty($mailin) AND !empty($passwordin))
{
$requser = $bdd->prepare("SELECT * FROM members WHERE mail = ? ");
$requser->execute(array($mailin));
$userexists = $requser->rowCount();
if($userexists == 1)
{
$userinfo = $requser->fetch();
if(password_verify($passwordin, $userinfo['password']))
{
$_SESSION['id'] = $userinfo['id'];
$_SESSION['username'] = $userinfo['username'];
$_SESSION['mail'] = $userinfo['mail'];
header("Location: index.php");
}
else
{
$error = "Wrong password";
}
}
else
{
$error = "Mail doesn't exist";
}
}
else
{
$error = "Please fill all the fields";
}
}
?>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- META -->
<title>CRIT | Calendar</title>
<!-- CSS -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Anton" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.3.1/css/flag-icon.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="css/mystyles-table.css">
<!-- CSS -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-133907448-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-133907448-1');
</script>
</head>
<body>
<header>
<?php
if (isset($_SESSION['id']))
{
$getid = intval($_SESSION['id']);
$requser = $bdd->prepare("SELECT * FROM members WHERE id = ? ");
$requser->execute(array($getid));
$userinfo = $requser->fetch();
?>
<table class="user">
<tr>
<td class="user-help">
<a href="edityourprofile.php">Edit</a><br />
<a href="logout.php">Log out</a>
</td>
<td>
<p class="welcomeuser"> Hi <a href="profil.php?id=<?php echo $userinfo['id']; ?>"><?php echo $userinfo['username']; ?></a> ! </p>
</td>
</tr>
</table>
<?php
}
else
{
?>
<table class="user">
<form action="" method="POST">
<tr>
<td class="user-help">
<a href="signup.php">Register</a><br />
<a href="#">Forgot password?</a>
</td>
<td>
<input type="mail" placeholder="username" name="mailin" />
</td>
<td>
<input type="password" placeholder="password" name="passwordin" />
</td>
<td>
<input type="submit" name="signin" value="login" />
</td>
</tr>
</table>
</form>
<?php
}
if(isset($error))
{
echo $error;
}
?>
</header>
<section>
<h1><a href="index.php">FIXED GEAR RACES 2019 SEASON</a></h1>
<form class="searchbox" method="GET">
<input type="search" name="q" placeholder="" />
<input type="submit" value="Go" />
</form>
<table class="calendar">
<?php
if($get->rowCount() > 0) {
while($show = $get->fetch())
{
?>
<tr>
<td><?php echo $show['showracedate']?></td>
<td><?php echo $show['racename']?></td>
<td><span class="flag-icon flag-icon-<?php echo $show['country']?>"></span> <?php echo $show['town']?>, <?php echo $show['country']?></td>
</tr>
<?php
}
}
else {
?>
<br />
<br />
<p class="nothingfound">It looks like there's no race for what you're looking for...</p>
<?php
}
?>
</table>
</section>
<footer>
<p>If you are a race organizer and your race is not listed, feel free to DM me on <a href="https://www.instagram.com/dasffalt/" target="_blank">Instagram</a>.</p>
<ul class="icons">
<li>
<a href="https://www.flickr.com/photos/dasffalt/albums" target="_blank"><i class="fab fa-flickr has-text-black fa-2x"></i></a>
</li>
<li>
<a href="https://www.instagram.com/dasffalt/" target="_blank"><i class="fab fa-instagram has-text-black fa-2x"></i></a>
</li>
</ul>
</footer>
</body>
</html> |
Partager