Click here to Skip to main content
15,033,917 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
include_once 'connection.php';

	header("Location: userhome.php");

	$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'");
	$count = mysql_num_rows($res); // if uname/pass correct it returns must be 1 row
	if($count == 1 && $row['user_pass']==md5($upass))
		$_SESSION['user'] = $row['user_id'];
		header("Location: userhome.php");
        <script>alert('Username / Password Seems Wrong !');</script>
<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" />
<div id="login-form">
<form method="post">
<table align="center" width="30%" border="0">
<td><input type="text" name="email" placeholder="Your Email" required /></td>
<td><input type="password" name="pass" placeholder="Your Password" required /></td>
<td><button type="submit" name="btn-login">Sign In</button></td>
<td><a href="admin/adminlogin.php">Click here for Admin Login</a></td>
<td><a href="register.php">Sign Up Here</a></td>
<div id="Div_Footer">
		<a href="home.php">HOME</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href="usermovies.php">MOVIES</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href="contactus.php">CONTACT US</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href="aboutus.php">ABOUT US</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href="usernews.php">NEWS</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

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 (, 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("", "21402449", "21402449") or die(mysql_error());
mysql_select_db("21402449") or die(mysql_error());

echo "<h>Connected to database";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900