@Pajimola wrote:
The status is fine but then the data return is null.
What i want to do is that the localstorage value which i put into a variable "userid" will be used in my php code.
Here is my code.
controller.jsvar _this = this;
var link = 'http://127.0.0.1/mobile/subject.php';
var userid = localStorage.getItem('loginDetails');
console.log(userid);$http.post(link, {userid}).then(function(res){ console.log(res); _this.response = res.data; })
this is my php code
<?php
header("Access-Control-Allow-Origin: *");
require_once('connection.php');$post_data = file_get_contents('php://input'); $request = json_decode($post_data); $userid = $request->userid; $subject_sql ="SELECT SubjectName FROM subjects WHERE userid = '" .$userid. "' "; $result = $con->query($subject_sql);
$re=$result->fetch_assoc();
echo json_encode($re);?>
Posts: 1
Participants: 1