I have a chrome extension that only runs on Facebook and I am trying to send data that the extension gathers to a MySQL database that I have on my GoDaddy website server. I keep getting the error message "Failed to load resource: the server responded with a status of 500 (Internal Server Error)". I wasn't sure what the issue is since I'm just getting into web development. Here is my code for the content script on my chrome extension:
var dummyUrl = new URL ("http://www.bbc.com/news/world-us-canada-41081629");
console.log("dummyUrl: " + dummyUrl);
//Create XMLHttpRequest Object
var xhttp = new XMLHttpRequest();
//Send request
xhttp.open("POST", "https://pocketchange.social/data.php", true);
xhttp.send(dummyUrl);
And here is my PHP file on my webserver that is running a query to send the data to my database:
<?php
$mysqli = new mysqli("localhost", "Jarid", "Database", "myURL");
//Check connection
if(mysqli === false) {
die("ERROR: Could not connect" . $mysqli->connect_error;
}
//Print host information
echo "Connection successful. Host info: " . $mysqli->host_info;
//Escape user inputs
$url = $mysqli->real_escape_string($_REQUEST['url']);
$description = $mysqli->real_escape_string($_REQUEST['description']);
$keywords = $mysqli->real_escape_string($_REQUEST['keywords']);
$content = $mysqli->real_escape_string($_REQUEST['content']);
$language = $mysqli->real_escape_string($_REQUEST['language']);
//Execute query
$query = "INSERT INTO url_data (url, description, keywords, content, language) VALUES ('$url', '$description', '$keywords', '$content', '$language')";
//Checking to see if values were inserted properly
if($mysqli->query($query) === true) {
echo "Data successfully inserted.";
}
else {
echo "ERROR could not execute query" . $mysqli->error;
}
$mysqli->close();
?>
Is my issue mainly that I'm trying to send data to a completely different server? I'm not super clear on how all of these pieces communicate with each other (ie how does the chrome extension know how to connect to the GoDaddy server, and how exactly is the php file sending data to the database, etc.) Thanks in advance.