I've coded a forum via php on my localhost(appserv and xampp). But when i try to publish my code on my webiste i get HTTP ERROR 500(https://gyazo.com/0ecdb91efa5d2b256416ecc0e7031dc8, Site dosen't work).
This site is made to check when the user click the login button, if the user exists and what role the user has. Then set a session to the value, if the user is logged in or not and what role the user has.
<?php
if(isset($_POST['submitlogin'])) {
$link = mysqli_connect('secret', 'secret', 'secret', 'secret');
if(!$link) {
echo 'We are having trouble connecting to the database.';
exit;
}
$userLogin = $_POST['usernamelogin'];
$passLogin = $_POST['passwordlogin'];
$query = "SELECT * FROM personinfo WHERE Name='$userLogin' and Password='$passLogin'";
$result = mysqli_query($link, $query);
$posts = mysqli_fetch_all($result, MYSQLI_ASSOC);
foreach ($posts as $post)
{
if ($userLogin == $post['Name'] && $passLogin == $post['Password']) {
session_start();
$_SESSION['login'] = $userLogin;
$_SESSION['loginpass'] = $passLogin;
if ($post['Administrator'] == 1) {
$_SESSION['Admin'] = '1';
}
else if ($post['Moderator'] == 1) {
$_SESSION['Mod'] = '1';
}
echo 'Correct information';
}
header("refresh:0; url=../");
}
}
Aucun commentaire:
Enregistrer un commentaire