Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7429795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:02:04+00:00 2026-05-29T09:02:04+00:00

I was trying to make a popup php form and login popup pages and

  • 0

I was trying to make a popup php form and login popup pages and I fortunately I got some notes and resources from the net on how to design and create what I was up to. The only problem now is that whenever I submit the form or the login popup page, the error messages throw the page back from the popup to original page, which is not what I want. I believe there is a way how to do the validation in the same login/ form page that can take place in the same popup window. any idea how to do that??

Looking forward to hearing from you.

if a code or anything related is required, I would post it here and update the original question.

update#1: here is the code. P.S. this code goes between the body tages

<?php

if ($username && $userid){
    echo "You are already logged in as <b>$username</b>. <a href='./member.php'>Click here</a> to go to the member page...or <a href='./logout.php'>Logout</a>";
}
else{
    $form = "<form action='./login.php' method='post' id='loginform'>
    <table>
    <tr>
        <td>Username:</td>
        <td><input type='text' name='user' /></td>
    </tr>
    <tr>
        <td>Password:</td>
        <td><input type='password' name='password' /></td>
    </tr>
    <tr>
        <td></td>
        <td><input type='submit' name='loginbtn' value='Login' /></td>
    </tr>
    <tr>
        <td><a href='./register.php'>Register</a></td>
        <td><a href='./forgotpass.php'>Forgot your password?</a></td>
    </tr>
    </table>
    </form>";

    if ($_POST['loginbtn']){
        $user = $_POST['user'];
        $password = $_POST['password'];

        if ($user){
            if ($password){
                require("connect.php");

                $password = md5(md5("kj87fiJAR46ufj".$password."Fj754456fj"));
                // make sure login info correct
                echo"$password";
                $query = mysql_query("SELECT * FROM users WHERE username='$user'");
                $numrows = mysql_num_rows($query);
                if ($numrows == 1){
                    $row = mysql_fetch_assoc($query);
                    $dbid = $row['id'];
                    $dbuser = $row['username'];
                    $dbpass = $row['password'];
                    $dbactive = $row['active'];

                    if ($password == $dbpass){
                        if ($dbactive == 1){
                            // set session info
                            $_SESSION['id'] = $dbid;
                            $_SESSION['username'] = $dbuser;

                            echo "You have been logged in as <b>$dbuser</b>. <a href='./member.php'>Click here</a> to go to the member page.";

                        }
                        else
                            echo "You must activate your account to login. $form";
                    }
                    else
                        echo "You did not enter the correct password. $form";
                }
                else
                    echo "The username you entered was not found. $form";

                //mysql_close();
            }
            else
                echo "You must enter your password. $form";
        }
        else
            echo "You must enter your username. $form";
    }
    else
        echo $form;
}
?>

and there is a code for the popup.

update#2: If found a similar tut that show how to build a complete login page with popup so I;m going to start from there: enter link description here

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:02:05+00:00Added an answer on May 29, 2026 at 9:02 am

    Use ajax to do so.

    For the login example:

    send and ajax request with the credentials

    do an action via javascript, depending on the result received by the server. For example, if request result is false show an error, if result is true close the popup and redirect the parent window if needed.

    Just an example (neither tested nor working) to guide you do this

    1) Include the ajax requests on the js code included in your popup

    //create the request object
    if (window.XMLHttpRequest) {
      request = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
      request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    //send the request (you can do it via post or get)
    if (request) {
      request.onreadystatechange = checkAjaxResponse;
      request.open("POST", "your_server_file_that_generates_ajax_response.php", true);
      request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      request.send("post params you want to include like param1=value");
    }
    
    /**
    * Ajax callback function, this should handle your ajax response
    */
    function checkAjaxResponse() {
    
      //check what was de ajax response
      if (request.readyState == 4) {
        if (request.status == 200) {
          xml_response = request.responseXML;   //you can do this with xml, json, ...
        }
      }
    
      //manipulate your response as needed, and take actions depending on if result is correct or not
      if (manipulated_data_from_the_response !== 'the answer you specified as right') {
        close_popup();
      }
      else {
        show_wrong_credentials_message();
      }
    }
    

    2) Implement your php file (or preferred server side languaje) to login the user and generate the http response
    //your_server_file_that_generates_ajax_response.php

    <?php
    
      function authenticateUser($user, $password) 
      {
        $query = "SELECT user_id FROM users_table WHERE user = $user AND password = $password LIMIT 1";
    
        //connect to your database, then make the query 
        $result = mysql_query($query);
        $row = mysql_fetch_row($result);
    
        //return the response you want    
        if ($row['user_id']) {
          $res = true; 
        }
        else {
          $res = false;
        }
    
        return $res;
      }
    
    
      //main actions
      echo authenticateUser($_POST['user'], $_POST['password']);
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a little JScript popup that displays information from the form
I am trying to make a Login popup window. For example, if someone clicked
I'm trying to make work this example from http://developer.android.com/resources/tutorials/views/hello-timepicker.html , no errors while compiling
I am trying to make a popup dialog form with jQuery UI, but the
I'm trying to make a draggable popup with Jquery and I'm following the advice
I'm trying make a login window where a user is prompted to enter their
Trying to make the infamous checkall checkbox for dynamically created rows from a MySQL
im trying to make a popup that comes up to confirm a users action
I'm trying to make our popup messages boxes have more appropriate text, rather than
No, I'm not trying to make an annoying popup. I have a simple webpage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.