Sari6t Posted January 31, 2017 Share Posted January 31, 2017 I've learned so much over these last number of weeks and if I can get this one I'll be super happy. I've been working on various ways to communicate prim to prim across the grid, I've used 3 prim chat relay, not bad, I' ve used email, slow and address issues and finally descided that an external server is the best scalable solution.So, I have it up and running mySQL and PHP and thanks to a ton of snippets of code I have a semi working setup. I can write to the database easy enough and sending useful bit of data I didnt know existed until now has helped to shape the future design on this relay grid wide com system. That being said I am perplexed as to how to retrieve the information from the database. ....<Insert loads of snickering from smart people here> :)Thing is this. It all about the llHTTPRequest, and http_response and of course the PHP page that handles the request . But my mind is soup after so much input and I could really use someone to demonstrate the thing I am missing in the simplest form. Or even point to something that does. I'v eread jsut about every article on Google and sadly some are really close but leave out the one thing I need or it from the an SL archive that links to something even older :( and that is no longer available. This is what I have, its messy , not secure and likely will send shudders down the spine of many,<?php include_once("THIS IS SECURITY LOL/db_conx.php"); $user_key = $_POST["user_key"]; //incoming userkey $user_name = $_POST["user_name"]; // Incoming user name $URL1 = $_GET["URL1"]; // URL $URL2 = $_POST["URL2"]; // URL $consoleID = $_POST["consoleID"]; // Console ID $table = "tardis"; //Connecting to your database mysql_connect($hostname, $username, $password) OR DIE ("Unable to connect to database! Please try again later."); mysql_select_db($dbname); //Fetching from your database table. $query = "SELECT URL1 FROM tardis WHERE tardisowner='ManwithFezz' "; $result = mysql_query($query); if ($result) { while($row = mysql_fetch_array($result)) { echo "URL: " . $row["$URL1"]; } } ?> ///////////////////////// SL Script /////////////////////////////////////////// key myHTTPRequest; list params = [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"]; string url = "http://example.com/Register_URL.php"; key user_key; string user_name; key rlReq = NULL_KEY; string smURL; string URL2 ; string URL1; string consoleID ; default { state_entry() { } touch_start(integer number) { myHTTPRequest = llHTTPRequest (url, params, "user_key=" + (string) user_key + "&user_name=" + user_name + "&URL1=" + (string)URL1 + "&URL2=" + (string)smURL + "&consoleID=" + (string)consoleID); } http_response (key request_id, integer status, list metadata, string body) { if (request_id == myHTTPRequest) { llOwnerSay("Details: " + body); llOwnerSay("PRIM UUID: " + (string) llGetKey()); llOwnerSay("URL:" + (string)URL1); } } } When I click the prim it returns the ECHO text but no data and I get the PRIM UUID but that I know why . Ahh my brain thanks anyone who can help. Long stroll in the sun required. :) Link to comment Share on other sites More sharing options...
Sari6t Posted February 1, 2017 Author Share Posted February 1, 2017 Yay me, I figured it out and it totally works now. woot woot I can POST and GET anything. So a little planning and I think a new grid wide system is born Can I Kudo myself? lol Nahhhhh 1 Link to comment Share on other sites More sharing options...
Kostya Noyes Posted February 2, 2017 Share Posted February 2, 2017 In php script you can get data: $data = file_get_contents("php://input");if (!empty($data)) { parse_str($data, $postdata);} else { $postdata = $_REQUEST;}$user_key = $postdata["user_key"]; //incoming userkey$user_name = $postdata["user_name"]; // Incoming user name$URL1 = $postdata["URL1"]; // URL $URL2 = $postdata["URL2"]; // URL$consoleID = $postdata["consoleID"]; // Console ID Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now