Im already have a android app connected to my database so that it logs in i need to do the same for a website but im am having trouble.
I cant seem to get it to work
Im using php my admin for the databases.
Is there a away to connect both the app and the website so users can log in. I have not been able to successfully so far.
Connection.php
<?php
define('DB_SERVER', 'localhost:3036');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'rootpassword');
define('DB_DATABASE', 'database');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
?>
logingpage.php
<?php
include("connection.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
$username = mysqli_real_escape_string($db,$_POST['username']);
$password = mysqli_real_escape_string($db,$_POST['password']);
$sql = "SELECT id FROM user WHERE username = '$username' and
passcode'$password'";
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row['active'];
$count = mysqli_num_rows($result);
if($count == 1) {
session("username");
$_SESSION['login_user'] = $username;
header("location: Logged_In.php");
}else {
$error = "Login Incorrect";
}
}
?>
Aucun commentaire:
Enregistrer un commentaire