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

  • Home
  • SEARCH
  • 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 8888737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:06:18+00:00 2026-06-14T22:06:18+00:00

I have a php script, only for learning purposes. I would like to use

  • 0

I have a php script, only for learning purposes. I would like to use on my web app ajax form. Never did it, this is testing php script. So I would like to send via ajax form name and password, in php script will be checked if its correct and it will return either success(when login and password correct) or error(when no match). My problem is how to send it and receive it correctly in js or jQuery. Anyone who could help me maybe with better idea and/or better secure function of doing this?

I found on stackoverflow and tryed this script:

    //bind an event handler to the submit event for your login form
    $('#login_form').live('submit', function (e) {

        //cache the form element for use in this function
        var $this = $(this);

        //prevent the default submission of the form
        e.preventDefault();

        //run an AJAX post request to your server-side script, $this.serialize() is the data from your form being added to the request
        $.post($this.attr('action'), $this.serialize(), function (responseData) {

        //in here you can analyze the output from your server-side script (responseData) and validate the user's login without leaving the page
});
});

And I was wondering if in php script it could work like this?:

<?php
$username = $_GET["name"];
$password = $_GET["password"];

if($username="*****" && $password==********)
{
header('Location:http://*****************/jaz/imes/index.html?login="success"');
}else{
header('Location:http://*****************/jaz/imes/index.html?login="error"');
}
?>

And as I said this is just a test script just for learning more about it.

  • 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-14T22:06:18+00:00Added an answer on June 14, 2026 at 10:06 pm

    First of all, try to use on() method if you’re using jQuery 1.8+
    Another thing is that you should set the session for that user in the PHP script, then redirect the user using the js:

    jQuery:

    $('#login_form').on('submit', function(){
            $.post($this.attr('action'), $this.serialize(), function (responseData) {
                if(responseData == 'success'){
                    window.location = "userpanel.php"
                }else{
                    alert('NO MATCHES');
                }
            });
    });
    

    PHP:

    <?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    // VALIDATING HERE, in db maybe?
    if($username == 'blah' && $password == 'blah'){
        $_SESSION['username'] = $username;
        echo "success";
    }else{
        echo "failed";  
    }
    
    ?>
    

    And in your HTML form you need to have 2 inputs with IDs as “username” and “password” so the above code could work.

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

Sidebar

Related Questions

I have a php script which i would need the following 3 web browsers
I have PHP script works without problems, like this : while($row4 = mysql_fetch_array($result4)) {
I have a php script that inserts data from an Android app into a
I have a PHP script that very much like a commenting system, but requires
I have a php script that only produces logs to the client. When I
I have the following question: how can I run a php script only once?
I have a call to this php script (only part in question displayed) if
Regarding Uploadify Hello, Currently I have a PHP only upload script and I'm planning
I have PHP script that fetch messages from a mailbox. I use the imap_search
I have PHP page where users can upload photos (using Ajax & PHP script).

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.