pls whats wrong with my popup login script

Discussion in 'PHP' started by adsegzy, May 24, 2012.

  1. #1
    I have a popup login script in which once a visitor clicks on LOGIN link on any page, login form will popup. The script is as below.

    
    <style type="text/css">
       #popupbox{
       margin: 0; 
       margin-left: 40%; 
       margin-right: 40%;
       margin-top: 50px; 
       padding-top: 10px; 
       width: 20%; 
       height: 150px; 
       position: absolute; 
       background: #FBFBF0; 
       border: solid #000000 2px; 
       z-index: 9; 
       font-family: arial; 
       visibility: hidden; 
       }
       </style>
       <script language="JavaScript" type="text/javascript">
       function login(showhide){
         if(showhide == "show"){
             document.getElementById('popupbox').style.visibility="visible";
         }else if(showhide == "hide"){
             document.getElementById('popupbox').style.visibility="hidden"; 
         }
       }
       </script>
    
     <div id="popupbox"> 
    <?php
    if(isset($_POST[Submit11])){
    $email=stripslashes($_POST[email]);
    $pword=stripslashes($_POST[pword]);
    $pw=md5($pword);
    
    if($email=="") echo "Enter your Email.<br>";
    elseif($pword=="")  echo "Enter your Password.<br>";
    else { echo "<b>Welcome</b><br>";
    echo "<meta http-equiv='refresh', content='2'>";}
    }
    ?>
     <form name="login" action="" method="post">
     <center>Username:</center>
     <center><input name="username" size="14" /></center>
     <center>Password:</center>
     <center><input name="password" type="password" size="14" /></center>
     <center><input type="submit" name="submit" value="login" /></center>
     </form>
     <br />
     <center><a href="javascript:login('hide');">close</a></center> 
     </div>
    
     <a href="javascript:login('show');">login</a>
    
    PHP:
    My problem here is that once the visitor clicks on "login" button on the pop up window without entering his username or password, the window will just disappear instead of echoing "Enter your Username or password". Also if the member enters his username and password correctly, the window will just disappear instead of echoing welcome and refresh the page on which the member clicked login.

    Pls what do I do wrong. Thanks
     
    adsegzy, May 24, 2012 IP
  2. kids

    kids Active Member

    Messages:
    411
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    68
    #2
    Wrong here

    if(isset($_POST[Submit11])){

    and here

    <input type="submit" name="submit" value="login" />
     
    kids, May 24, 2012 IP
  3. adsegzy

    adsegzy Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Kids. I have corrected as below

    if(isset($_POST[submit11])){
    $email=stripslashes($_POST);
    $pword=stripslashes($_POST[pword]);
    $pw=md5($pword);

    if($email=="") echo "<span class='red'>Enter your Email.</span><br>";
    elseif($pword=="") echo "<span class='red'>Enter your Password.</span><br>";
    else echo "<span class='green'><b>Welcome</b></span><br>";
    }
    ?>
    <form name="login" action="" method="post">
    <center>Email:</center>
    <center><input name="email" size="14" /></center>
    <center>Password:</center>
    <center><input name="pword" type="password" size="14" /></center>
    <center><input type="submit" name="submit11" value="login" /></center>
    </form>

    but still doing the same thing (disappearing). what else?
     
    adsegzy, May 25, 2012 IP
  4. TeemuGr

    TeemuGr Greenhorn

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #4
    <center><input type="submit" name="submit11" value="login" /></center>
    Code (markup):
    to

    <center><input type="submit" value="login" /></center>
    <input type="hidden" name="submit11" value="login" />
    Code (markup):
     
    TeemuGr, May 25, 2012 IP