Jump to content

need help in making login with tabs


doforumda

Recommended Posts

Hi

I want to create a login system. what i want is there is a tab of login when user clicks on it an external html file is loaded with login form so when user enters username and password and clicks login then it goes to php file using ajax and checks there to login. what i am facing with following code it does not display whe user login successfully.

 

what am i a doing wrong here

 

this is main page named loginTab.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery-1.4.min(Production).js" type="text/javascript"></script>
<title>Untitled Document</title>
<script>
function tabOne() {
$('div#message').load('jquery+ajax+php2.html');
}
</script>
<style>
.tabs {
width: 100px;
height: 25px;
border: 1px solid black;
cursor: pointer;
}
</style>
</head>

<body>
<div class="tabs" onclick="tabOne()">Tab One</div>
<div id="message"></div>
</body>
</html>

 

this is login form page named login.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery-1.4.min(Production).js" type="text/javascript"></script>
<script>
var url = 'login.php';
var user = $('input#user').val();
var pass = $('input#pass').val();

var queryString = 'user=' + user + '&pass=' + pass;
function login () {
      $.ajax(url,
	{
        method: 'POST',
        data: queryString,
        dataType: 'html',
        onComplete: display 
      	}); 
}
function display(data) {
          $("#content").html(data);
}
</script>
<title>Untitled Document</title>
</head>
<body>
<div id="content"></div>
<form>
   Username:<br />
   <input type="text" name="user" id="user" /><br />
    Password:<br />
    <input type="password" name="pass" id="pass" /><br />
    <input type="button" name="submit" id="submit" value="Login" onclick="login()" />
</form>
</body>
</html>

 

this is php file named login.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
$email = strip_tags($_POST['user']);
$password = strip_tags($_POST['pass']);

//echo $email;
//echo $password;

if($email&&$password) {

$connect = mysql_connect("localhost","user","password");
mysql_select_db("facebook");
$query = mysql_query("SELECT email FROM users WHERE email='$email'");
$count = mysql_num_rows($query);
if($count == 0) {
	echo "You are registered thanks.";
}
else {
	die("That email address already exist.");
}
}
else {
die("please fill in both fields!");
}
?>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.