• 3
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

server response null when $_POST is used

php code :

<?php
header("Content-type:application/json");
require "db_conn.php";
$user_name = $_POST["user_name"];
$user_pass = $_POST["pwd"];
$mysql_qry = "select * from user_accounts where user_name like '$user_name' and pwd like '$user_pass';";
$result = mysqli_query($conn,$mysql_qry);

if( $num_rows = mysqli_num_rows($result) > 0 ){
while( $row = mysqli_fetch_array($result)){
array_push($response,array("user_name"=>$row['user_name'],"first_name"=>$row['first_name'] , "last_name"=>$row['last_na$}
echo json_encode(array("server_response"=>$response));

//echo json_encode(array("result"=>123));
}else{
echo "login fail";
}

?>

I get my response as : {"server_response":null}

but if i uncomment the sample output and comment the other part i get output as : {"result":123}

also for some reason instead of $_POST if i were to initialize the variables directly i get the correct output