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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:29:41+00:00 2026-05-28T13:29:41+00:00

function logsig() { var username = $(#username).val(); var password = $(#password).val(); var dataString =

  • 0
function logsig() {
    var username = $("#username").val();
    var password = $("#password").val();
    var dataString = '&username=' + username + '&password=' + password;
    if(username=='' ||  password=='') {
        $('#success').fadeOut(400).hide();
        $('#error').fadeOut(400).show();
    } else {
        $.ajax({
        type: "POST",
        dataType: "JSON",
        url: "<?=base_url()?>index.php/home/logsig",
        data: dataString,
        json: {session_state: true},
        success: function(data) {
        if(data.session_state == true) {
            window.location = "<?=base_url()?>";
        } else if(data.session_state == false) {
            $("#login_failure").fadeIn(400);
        }
      }
   });
}
}

How can I pass multiple json encoded values to my form above. What I’m doing is if user logs in, ‘session_state’ is passed, and if user has a ‘pending’ account, ‘pending’ is passed. Both json values have an expression to be executed.

public function logsig() {
    header('Content-type:application/json');
    $postedEmail = $this->input->post('username');
    $password = $this->input->post('password');
    $hashedPass = $this->encrypt->sha1($password);
    $query = $this->db->query("SELECT * FROM users WHERE username = '{$postedEmail}' AND password = '{$password}'");
    if ($query->num_rows() > 0) { // if user is already registered and is logging in, execute the following sql/php commands.
        $row = $query->row();
        if ($row->status == "pending") {
            echo json_encode(array('pending' => true));
        } else {
            echo json_encode(array('pending' => false));
        }
        //$this->session->set_userdata('userid', $idgen);
        //$this->session->set_userdata('email',  $postedEmail);
        $this->session->set_userdata('logged', "1"); // 1 means user is logged in.
        echo json_encode(array('session_state' => true));
    } else {
        echo json_encode(array('session_state' => false)); // false sends to jquery that member isn't registered
    }
}
  • 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-28T13:29:42+00:00Added an answer on May 28, 2026 at 1:29 pm

    You should collect all your data and at the end output it as the single JSON string. For example:

    $output= array();
    
    if ($query->num_rows() > 0) {
        $row = $query->row();
    
        // Status flag
        $output['pending'] = $row->status == "pending";
    
        $this->session->set_userdata('logged', "1"); // 1 means user is logged in.
    
        // Session state
        $output['session_state'] = true;
    }
    else {
        $output['session_state'] = false;
    }
    
    header('Content-type: application/json');
    die(json_encode($output));
    

    Or in this case even better (optimized true-branch):

    $row = $query->row();
    $this->session->set_userdata('logged', "1"); // 1 means user is logged in.
    
    // Session state
    $output = array(
        'pending'       = $row->status == "pending",
        'session_state' = false
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function check(id){ var _id = document.getElementById(id); url = test.php?check=1&id= + _id; } i want
function example(){ var quantity = http://www.example.com/index.php?brandid=b%123&quantity=20; quantity = quantity.replace(-what regular expression should i user-,
function dowork() { $(.wrappedElement).removeClass(wrappedElement); $(.wrappedElementout).removeClass(wrappedElementout); var a=$(div#DepPart select option:selected).val(); $(div#TestPart select option[value^=a]).addClass(wrappedElement); $(div#TestPart select
function controllaFoto(target, username) { var _URL = window.URL || window.webkitURL; var img = new
function getUsername() { var userName = document.form.screen_name.value; document.getElementById(display).innerHTML = userName; var apiName = https://api.twitter.com/1/users/lookup.json?screen_name=
function ajaxFunction2(){ var chooser2 = $('#chooser2').val(); $('#floatcontainertop').css(background,$('#chooser2').val()); } Could someone please tell me how
function checkInputData() { $('.mainSearchSubmit').live('click', function () { var inputData = $(this).parent().children().eq(0).val(); console.log(inputData.length); //this returns
function validate() { var textbox= $(#inputtextbox).val(); var match = /^([a-zA-Z0-9]{1,})$/; if(!match.test(textbox)) { $(#dataError).text('Min 1
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
function register_contact ($person = array()) { $nogood = false; foreach ($person as $val) {

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.