Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
login form as pop up window
Old 10-22-2009, 08:23 AM login form as pop up window
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
hi,

can any one help me in having a login form as a popup window,
where ever i click sign in button in my site the popup must be opened in the page where i have been in .

please can any one help me in this

thanking u in advance
lakshmiyb is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-22-2009, 08:58 AM Re: login form as pop up window
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,515
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
two ways both involve javascript rather than PHP.

1/ put the form into every pge in the site and hide it using CSS, the the login link shows the form.

2/ use javascript to write the form into the page when the login link is clicked.

a popup window" would not be "in the same page"
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-22-2009, 12:46 PM Re: login form as pop up window
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I would use jQuery (a javascript library) to load the form page into a div with AJAX. Kind of chris' alternative 2. A short example:
Code:
$(document).ready(function(){
   $("#login_button").click(function(){
      $("#login_form").load("login.php");
   });
});
That would load the page login.php (in which you place the actual form) into a div with the id 'login_form' whenever a link/button with the id 'login_button' is pressed. You can download the jQuery library from their website.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-22-2009, 02:38 PM Re: login form as pop up window
frih's Avatar
Super Talker

Posts: 139
Name: abhi
Location: http://www.techbusy.org/
Trades: 0
You have to use javascript for this, you can search for the code on the google. I don't remember it.
__________________

Please login or register to view this content. Registration is FREE
|

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
frih is offline
Reply With Quote
View Public Profile Visit frih's homepage!
 
Old 10-24-2009, 07:47 AM Re: login form as pop up window
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
thanku very much i got the problem solved by javascript

but the thing i have the problem with is,
when i login i need to go to the page where i was in, but not to the samepage every time
and i am not able to display the error in the login form when wrong email& password is entered.

here is my code
can u help me in this
PHP Code:
$result mysql_query("SELECT * FROM users where email='".$email."' AND password='".$password."'");
   if(
$row=mysql_fetch_array($result))
   {
    
$_SESSION['Email']=$email;
    
$_SESSION['msg']="Welcome".$email;
   
//echo "email exist";
      
header("Location:homepage.php");
   }
   else{
    
$msg2 "check USERNAME & PASSWORD";
              
$_SESSION['msg']="Please".$msg2;
    
//echo "email doesnot exist";
    
header("Location:loginpage.php");
   } 
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-24-2009, 01:16 PM Re: login form as pop up window
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
If you chose my solution for the form, using jQuery, you can just add an event handler for the submit process, so that you send the form with AJAX instead and thereby login without reloading the page. Then you can just show the result in the same popup window.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-24-2009, 05:21 PM Re: login form as pop up window
Novice Talker

Posts: 5
Trades: 0
ya i can help you... if you want to use pop up menu for login then please use Vbscript and input box... if any problem then reply...
__________________
Henry
Please login or register to view this content. Registration is FREE
henry21r is offline
Reply With Quote
View Public Profile
 
Old 10-24-2009, 05:47 PM Re: login form as pop up window
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,515
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
VBScript???

This IS the PHP forum.

Here is how you can "popup" a form in the same page. Input errors can be handled by overriding the CSS and showing the form with error messages.

http://www.modtalk.lcl/_site/code/ja...de/login-form/ just roughly done for now.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 10-24-2009 at 05:51 PM..
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-26-2009, 04:29 AM Re: login form as pop up window
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
hey i got the pop up window,
but i need the help to login to the page i was in
i.e, where i get the pop up,

as for my code i willbe loggied into the main page of my site

please help me in this.

thanku in advance.
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-26-2009, 04:40 AM Re: login form as pop up window
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,515
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
hey i got the pop up window,
but i need the help to login to the page i was in
That IS the point of using a form on the same page and have the login code included.

you WILL STAY ON THE SAME PAGE!!!!!!! after you are logged in (or not)

there is no need to have a separate "login page" and no need for redirecting.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-27-2009, 07:42 AM Re: login form as pop up window
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
thanku very much for ur suggestions
this is what i have the problem

<?php
session_start();
if(isset($_SESSION['Email'])){

}else{
header("Location:loginpage.php");
}
?>
this is what i am using for some pages to login
but i dont have separate page for loginpage i used popup winodw for login and used it in header page

what should i cal in palce of login page to get the popup window if session is not started
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-27-2009, 10:31 AM Re: login form as pop up window
gamegit's Avatar
Junior Talker

Posts: 1
Name: adham
Trades: 0
I have one on my site you can see it on www . gamegit.com

Last edited by chrishirst; 10-27-2009 at 05:44 PM..
gamegit is offline
Reply With Quote
View Public Profile Visit gamegit's homepage!
 
Old 10-27-2009, 11:24 AM Re: login form as pop up window
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
This is a very basic example, which I havn't tested (I wrote it here in the forum quick reply box), but should work. Try it out and work your way from there. Again, jquery can be downloaded from their website, jquery.com.

EDIT: In login.php there is a part where the comments say "do this yourself", you should implement that yourself :P

A page with a link to open the login popup.
HTML Code:
<html>
<head>
<title>Test</title>
<script type="text javascript" src="path/to/jquery.js">
<script type="text/javascript">
$(document).ready(function(){
   /* Hide the popup */
   $("#login_form").hide();

   /* Onclick function to show popup */
   $("#login_button").click(function(){
      $("#login_form").show().load("login_form.php");
   });
});
</script>
</head>

<body>
Click red box to login.
<div id="login_button" style="width:100px; height:50px; background-color:#f00;"></div>
<div id="login_form" style="width:600px; height:400px"></div>
</body>
</html>
The page that opens in the popup, login_form.php
HTML Code:
<script type="text/javascript">
 $(document).ready(function(){
   $("#login_submit").click(function(){

      // $.post(url, data, callback, type);
      $.post(
         "login.php",
         {uname: $("#uname").val(), pword: $("#pword").val()},
         function(data) {
            // data contains array produced in login.php
            if (data.status == 'error') {
               $("#msg").html(data.errorMsg).css('color' : 'red');
            } else {
               $("#msg").html("You have been logged in, reloading page...").css('color' : 'green');
               setTimeout("location.reload(true);",2);
            }
         },
         "json"
      );

      // do not send the form the "normal way"
      return false;
   });
 });
 </script>
<div id="msg"></div>
<form>
<p>Username: </p><input type="text" id="uname"><br />
<p>Password: </p><input type="text" id="pword"><br />
<input type="submit" id="login_submit">
</form>
}
And finally, the login.php file
PHP Code:
<?php

session_start
();

$return = array('status' => '''errorMsg' => '');

if (isset(
$_POST['uname']) && isset($_POST['pword'])) {
   if (empty(
$_POST['uname']) || empty($_POST['pword'])) {
      
$return['status'] = 'error';
      
$return['errorMsg'] = "Please enter both username and password";
   } else {
      
// validate username and password in database
      // do this yourself
      
if ($validated) {
         
// set sessions, like
         
$_SESSION['uname'] = $validatedUsername;
         
$return['status'] = 'success';
      } else {
         
$return['status'] = 'error';
         
$return['errorMsg'] = "Username or password incorrect, please try again.";
      }
   }
} else {
   
// could be someone who's trying to acces this page directly, just exit
   
exit();
}

// all output will be sent to jQuery via ajax, so just echo the result (in json format)
echo json_encode($return);

?>
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366

Last edited by lizciz; 10-27-2009 at 11:28 AM..
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-29-2009, 07:58 AM Re: login form as pop up window
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
thanku lizciz
i have worked on in previously, but i am not getting the pop up with that.
i have used the light box for my login for amd working fine.
but i have error in entering into the page
i am able to enter into only one page afterlogin
but i need to login into the page where i was in

as it as in www.gamegit.com
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-29-2009, 08:05 AM Re: login form as pop up window
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,515
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
which bit about a popup window being a different page are you not seeing?

I'll write some more code to demonstrate how a hidden form on the page will do EXACTLY what you want and how it can be utilised.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-30-2009, 04:41 AM Re: login form as pop up window
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
Thanku very much for all ur replays,
i got the doublt cleared and got the out put as i am in need of,
the thing is
i have placed
PHP Code:
<?php
 session_start
();
 if(isset(
$_SESSION['Email'])){
  
header("Location:moviepage.php");
 }else{
 
header("Location:loginpage.php");
 }
?>
in all the pages where i want the user to login,
but i am not able to enter into subpage of my menu,

i used menus in my main page,
the error is "web page has expaired";
what could i do to display my page as logen in user

what is the query i should use in the restricted page to login as i am using login form as lightbox.
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-30-2009, 05:29 AM Re: login form as pop up window
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,515
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
DON'T redirect as it may NOT be carrying the session information with it
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-30-2009, 01:25 PM Re: login form as pop up window
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
In the protected pages, check for the apropriate sessions and if they're not found redirect to login page. Otherwise do nothing (continue with the current page).

PHP Code:
session_start();
if (!isset(
$_SESSION['Email'])) {
   
header("Location: login.php");
}

// rest of your page here, as normal 
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-31-2009, 04:06 AM Re: login form as pop up window
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
this is my header of the page

and when login in i am getting that web page has expired
i am not knowing what is wrong in this
please hepl me

PHP Code:
<?php
$ebits 
ini_get('error_reporting');
error_reporting($ebits E_NOTICE);
session_start();
$error =""
$email $_POST['Email'];
$password $_POST['Password'];
if(
strlen($email)!=&& strlen($password)!=0)
  {
             include 
"dbconnection.php";
   
$result mysql_query("SELECT * FROM users where email='".$email."' AND password='".$password."'");
   if(
$row=mysql_fetch_array($result))
   {
    
$_SESSION['Email']=$email;
    
$_SESSION['msg']="Welcome".$email;
   
//echo "email exist";
    //header("Location:homepage.php");
   
}
   else{
    
$error ="Checkk email $ password";
   }
  }
 
?>
<!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>HEADER</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="lightbox-form.css">
<script src="lightbox-form.js" type="text/javascript"></script>
 
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="770" height="3" >&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0"  cellpadding="0" cellspacing="0">
  <tr>
    <td width="215" height="30">&nbsp;</td>
    <td width="28" height="30" align="center" valign="middle"><a href="moviepage.php">
    <img src="http://www.webmaster-talk.com/images/movie-icon.gif" alt="MOVIE" width="23" height="28" border="0" id="movie"/></a></td>
    <td width="10" height="30" align="center">|</td>
    <td width="28" height="30" align="center" valign="middle"><a href="TVpage.php">
    <img src="http://www.webmaster-talk.com/images/tv-icon.gif" alt="TV" width="26" height="28" border="0" /></a></td>
    <td width="300" height="30">
    <?php 
  
if(isset( $_SESSION['Email']))
  {
  echo 
"<font class='style1'>&nbsp;&nbsp;&nbsp;&nbsp;Welcome:&nbsp;".$_SESSION['Email']."</font>";
  }
  else {
  echo 
"<font class='style1'>&nbsp;&nbsp;&nbsp;&nbsp;Welcome Guest</font>";
  }
  
?>
    &nbsp;</td>
    <td width="25" align="center" valign="middle">
    <?php 
  
if(isset( $_SESSION['Email']))
  {  echo 
"<a href='signout.php' class='style1'><img src='images/SIGNOUT-LOGO.jpg' alt='SIGNIN' width='18' height='21' border='0' /> </a>";}
  else {
   echo 
"<div id='filter'></div>
<div id='box'>
  <span id='boxtitle'></span>   
   <form method='POST' action='#' target='_parent'>
<table width='98%' border='0' cellspacing='0'>
 
                    <tr>
                      <td width='47%'>&nbsp;&nbsp;&nbsp;&nbsp;<span class='style1'>Email ID </span></td>
                      <td width='53%'><input name='Email' type='text' size='11' /></td>
                      </tr>
                    <tr>
                      <td>&nbsp;&nbsp;&nbsp;&nbsp;<span class='style1'>Password</span></td>
                      <td><input name='Password' type='password' size='13' /></td>
                      </tr>
                    <tr>
                      <td>&nbsp;&nbsp;
                        <table width='100' border='0' cellspacing='0' cellpadding='0'>
                          <tr>
                            <td width='10'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td><a href='registerpage.php'><span class='style1'>Register</span></a></td>
                            </tr>
                          </table></td>
                      <td><input type='image' name='Submit' src='images/login.jpg' id=login_button/>   <input type='button' name='cancel' value='Cancel' onclick='closebox()' /></td>
                      </tr>
                    <tr>
                      <td colspan='2' align='center'>&nbsp;&nbsp;&nbsp;<a href='forgotpassword.php'><span class='style1'>Forgot Password </span></a></td>
                      </tr>
                    </table></form>  
</div>
<a href='#' onClick='openbox()'><img src='images/SIGNIN-LOGO.gif' alt='SIGNIN' width='23' height='26' border='0' /></a>"
;
  }
 
  
?>
 
   </td>
    <td width="50"><span class="style1">
 <?php 
 
  
if(isset( $_SESSION['Email']))
  {  echo 
"<a href='signout.php' class='style1'>SIGNOUT </a>";}
  else {
    echo 
"<div id='filter'></div>
<div id='box'>
  <span id='boxtitle'></span>
<form method='POST' action='#' target='_parent'>
<table width='98%' border='0' cellspacing='0'>
 
                    <tr>
                      <td width='47%'>&nbsp;&nbsp;&nbsp;&nbsp;<span class='style1'>Email ID </span></td>
                      <td width='53%'><input name='Email' type='text' size='11' /></td>
                      </tr>
                    <tr>
                      <td>&nbsp;&nbsp;&nbsp;&nbsp;<span class='style1'>Password</span></td>
                      <td><input name='Password' type='password' size='13' /></td>
                      </tr>
                    <tr>
                      <td>&nbsp;&nbsp;
                        <table width='100%' border='0' cellspacing='0' cellpadding='0'>
                          <tr>
                            <td width='10'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td><a href='registerpage.php'><span class='style1'>Register</span></a></td>
                            </tr>
                          </table></td>
                      <td><input type='image' name='Submit' src='images/login.jpg' id=login_button/>   <input type='button' name='cancel' value='Cancel' onclick='closebox()' /></td>
                      </tr>
                    <tr>
                      <td colspan='2' align='center'>&nbsp;&nbsp;&nbsp;<a href='forgotpassword.php'><span class='style1'>Forgot Password </span></a></td>
                      </tr>
                    </table></form> 
</div>
<a href='#' onClick='openbox()'>SIGNIN</a>"
;
  }
 
  
?></span></td>
    <td width="11" align="center">|</td>
    <td width="30" align="center" valign="middle"><a href="registerpage.php"><img src="http://www.webmaster-talk.com/images/register.jpg" width="18" height="21" border="0" /></a></td>
    <td width="60"><span class="style1"><a href="registerpage.php">REGISTER</a></span></td>
    <td width="110">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="205" height="173"><a href="homepage.php"><img src="http://www.webmaster-talk.com/images/main-img2 (1).gif" width="205" height="173" border="0" /></a></td>
      <td width="17" height="173"><img src="http://www.webmaster-talk.com/images/main-img2 (2).gif" width="19" height="173" /></td>
      <td width="546" height="173"><img src="http://www.webmaster-talk.com/images/main-img1.gif" width="546" height="173" /></td>
  </tr>
 
</table>
 
</body>
</html>
when page is refreshed i am loged in but until i refresh i am getting the IE page that page has expired.

Last edited by lakshmiyb; 10-31-2009 at 04:08 AM..
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-31-2009, 07:43 AM Re: login form as pop up window
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,515
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
that's because you are using a POST action to login. It's a standard browser message.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to login form as pop up window

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.54645 seconds with 12 queries