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 9186371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:30:39+00:00 2026-06-17T19:30:39+00:00

I have script from login page which through ajax sends data into php, and

  • 0

I have script from login page which through ajax sends data into php, and php returns if successful or not, I just wonder how can I change my scripts so it would send back also 2 variables and receive it in my login js script so I can create cookies? here are my js and php scripts:

js:

$(document).on('pageinit',function(){
        $("#login").click(function(){

            username=$("#usr").val();
            password=$("#psw").val();
            $.ajax({
                type: "POST",
                url: "http://imes.***********.com/php/login_check.php",
                data: "name="+username+"&pwd="+password,
                success: function(html){
                    //in case of success
                    if(html=='true')
                    {
                        $("#login_message").html("Logged in, congratulation.");
                        $.mobile.changePage("http://imes.***********.com/userpanel.php");
                    }
                    //in case of error
                    else
                    {
                        $("#login_message").html("Wrong username or password");
                    }
                },
                beforeSend: function() { $.mobile.showPageLoadingMsg(); }, //Show spinner
                complete: function() { $.mobile.hidePageLoadingMsg() } //Hide spinner
            });
            return false;
        });    

php:

<?php
session_start();
    $username = $_POST['name'];
    $password = $_POST['pwd'];
    include('mysql_connection.php');
    mysql_select_db("jzperson_imesUsers", $con);

    $res1 = mysql_query(
     "SELECT * FROM temp_login WHERE username='$username' AND password='$password'"
     );

    $num_row = mysql_num_rows($res1);
    if ($num_row == 1) {
        echo 'true';
    }
     else {
        echo 'false';
    }
?>
  • 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-06-17T19:30:40+00:00Added an answer on June 17, 2026 at 7:30 pm

    Try to use Json as response:

    PHP side

    ...
    $json = new Services_JSON();
    echo $json->encode("{a:1,b:2}");
    

    JS

    ...
     success:function(data){
                if(data)
                {
                 console.log(data.a);
                 console.log(data.b);
                 }
      ....
    

    You can encode any array in PHP and pass it as ajax callback.

    Json class you can get there

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried a session.php script which runs at the head of each page
Hi I have an ajax script which validates the users information put into textboxes.
I have this part of script from my GAE application which uses webapp2, which
I have a script that will get images from page, but how do I
I have a page called index.xhtml , in which I use variables from a
I am receiving vars from AS3 via php script and inserting into db. all
On my website I have a PHP script which (when user enters a username
I have a form on my .jsp page which sends a password back to
I have a page which I modified to accept input from the user and
I have a PHP page that uses PEAR Mail to send a message through

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.