<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
session_start();
include_once 'connection.php';
if(isset($_SESSION['user'])!="")
{
header("Location: userhome.php");
}
if(isset($_POST['btn-login']))
{
$email = mysql_real_escape_string($_POST['email']);
$upass = mysql_real_escape_string($_POST['pass']);
$email = trim($email);
$upass = trim($upass);
$res=mysql_query("SELECT user_id, user_name, user_pass FROM users WHERE user_email='$email'");
$row=mysql_fetch_array($res);
$count = mysql_num_rows($res);
if($count == 1 && $row['user_pass']==md5($upass))
{
$_SESSION['user'] = $row['user_id'];
header("Location: userhome.php");
}
else
{
?>
<script>alert('Username / Password Seems Wrong !');</script>
<?php
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Member and Admin login</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<center>
<div id="login-form">
<form method="post">
<table align="center" width="30%" border="0">
<tr>
<td><input type="text" name="email" placeholder="Your Email" required /></td>
</tr>
<tr>
<td><input type="password" name="pass" placeholder="Your Password" required /></td>
</tr>
<tr>
<td><button type="submit" name="btn-login">Sign In</button></td>
</tr>
<tr>
<td><a href="admin/adminlogin.php">Click here for Admin Login</a></td>
</tr>
<tr>
<td><a href="register.php">Sign Up Here</a></td>
</tr>
</table>
</form>
</div>
</center>
<br><br>
<div id="Div_Footer">
<a href="home.php">HOME</a>
<a href="usermovies.php">MOVIES</a>
<a href="contactus.php">CONTACT US</a>
<a href="aboutus.php">ABOUT US</a>
<a href="usernews.php">NEWS</a>
</div>
</body>
</html>
What I have tried:
Can anyone tell me whats wrong with my code. Somehow I managed to connect with xampp mysql server.
All my pages works fine, my logins , register.
But when test with with another host server via tcp/ip (202.20.5.105), I wasnt able to connect.
I have changed the hostname, username, password and database. my login pages shows up, except I am connect to database.
Here is my connection.php code
// Connects to Our Database
mysql_connect("202.20.5.105", "21402449", "21402449") or die(mysql_error());
mysql_select_db("21402449") or die(mysql_error());
echo "<h>Connected to database";
?>