I want to go to my homepage with a username and password already registered in my database. I tested my registration page... works perfect... but at the moment that I enter the recorded data, my page is not redirected.
My code is this:
<form class="formlog" method="POST" action=""/>
<pre>
<span>User</span>
<input type="text" id="user" name="user" autocomplete="off" placeholder="Your email here..." size="15" required/>
<span>Password</span>
<input type="password" id="pass" name="pass" autocomplete="off" placeholder="Your pass..." size="15" required/>
<button type="submit">Send!</button>
</pre>
</form>
<a href="reg.php">¿Dont have your account?... come here!!</a>
</div>
<?php
$host="----";
$username="----";
$password="----";
$db_name="----";
$tb_name="----";
$connect = mysqli_connect($host,$username,$password,$db_name)or die("Cannot connect to the database.");
$myusername=$_REQUEST['user'];
$mypassword=$_REQUEST['pass'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysqli_real_escape_string($myusername);
$mypassword = mysqli_real_escape_string($mypassword);
$sql = "select*from $tbl_name where User='$myusername' and Password='$mypassword'";
$result=mysqli_query($connect,$sql);
$count= mysqli_num_rows($result);
if($count==1){
session_register($myusername);
session_register($mypassword);
header("location:HomePAGE.html");
}else{
echo "<h3 align='center'><font color='Red'>Incorrect pass or user... try again.</font></h3><br>";
}
?>
Solved
Lol, my code worked with a crazy solution ... I place the PHP code in another separate file and I delete the following lines :
session_register($myusername);
session_register($mypassword);
¿Can anyone explain me what happened here?