• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

I'm writing a chrome extension that is connected to an external php server. There are two main things that my chrome app does regarding the interaction with ther server :
1. read the stored comments from the server and show it on the extension 2. if a user writes a new comment, send it to the server so it can store the comment in the MySQL DB.

The problem I have is that while my extension has no problem fetching information from the server, it constantly fails to send new comments to the server. Since the reading function works, I assume that I have no problem with the CORS or anything.

This is the code I wrote to read the info from the server.

        function getUrl() {     chrome.windows.getCurrent(function(w) {       chrome.tabs.getSelected(w.id,       function (response){           link = response.url;           //console.log(link);           hr = new XMLHttpRequest();           var info="link="+link;           //console.log(info);           hr.open("POST", "http://nardis.dothome.co.kr/nardis_core/comment_load.php", true);           hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");           hr.onload = () => {             const data = hr.responseText;             //console.log(data);             box.innerHTML += data;             //console.log(data);           };           hr.send(info);       });     });     } 

This is the code I wrote to send the information to the server.

function sendPost(){   chrome.windows.getCurrent(function(w) {     chrome.tabs.getSelected(w.id,     function (response){         //const title = document.getElementById('title').value;         const description = document.getElementById('comment').value;         link = response.url;         //console.log(link);         hr = new XMLHttpRequest();         chrome.storage.sync.get(['u_id'], function(result) {                   var info="description="+description+"&link="+link+"&u_id="+result.u_id;                   hr.open("POST", "https://nardis.dothome.co.kr/nardis_core/mention_create.php", true);                   hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");                   hr.send(info);                   location.reload();         });     });   }); }  
Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]