I have a simple login register form, when the user types in the wrong email then they are shown text saying "Email in use" however this text is done with a php echo and therefore i am unable to edit its styling and positioning. The only way i can think of is to use javascript instead of the php echo so that i can output the message to another div which is already styled. I want to output the message into the div id #log. I have tried $('#log').innerHTML = 'Your text.'; however this is not working.
Here is my code :
<?php
session_start();
include_once 'authentication/dbconnect.php';
if(isset($_SESSION['user'])!="")
{
header("Location: account.php");
}
if(isset($_POST['btn-login']))
{
$email = mysql_real_escape_string($_POST['email']);
$upass = mysql_real_escape_string($_POST['pass']);
$res=mysql_query("SELECT * FROM users WHERE email='$email'");
$row=mysql_fetch_array($res);
if($row['password']==md5($upass))
{
$_SESSION['user'] = $row['user_id'];
header("Location: account.php");
}
else
{
?>
<script>$('#log').innerHTML = 'Your text.';</script>
<?php
}
}
?>
<!DOCTYPE html>
<html>
<HEAD>
<title>Website | Loign</title>
<?php include "includes/page_sources.php"; ?>
</HEAD>
<body>
<?php include "includes/navigation.php"; ?>
<div id="wrapper">
<div id="log"></div>
<div id="login-form">
<form method="post">
<input type="text" name="email" placeholder="Your Email" required />
<input type="password" name="pass" placeholder="Your Password" required />
<button type="submit" name="btn-login">Log In</button>
<a href="register.php">Sign Up</a>
</form>
</div>
</div>
<?php include "includes/footer.php"; ?>
</body>
</html>