767 posts
Posted 16 May 2013 - 09:49 AM
Hello!
im having a quite big issue, with posting two or more variables to a website, but i dont think im posting correct:
http.post("http://advlock.webuda.com/lockP.php?", "key=" .. key .. ", licensekey=" .. computer[pos].key)
does anyone know if thats a valid posting method? (if not then please tell me what i need to add/remove)
and btw, the two variables "key" and "computer[pos].key" is some variables from an input / table.
Thanks in Advance
169 posts
Posted 16 May 2013 - 09:55 AM
http.post("http://advlock.webuda.com/lockP.php?", "key=" .. textutils.urlEncode(key) .. "&licensekey=" .. textutils.urlEncode(computer[pos].key))
I've never worked with the HTTP API, and I don't know the details of what you're doing, but try that.
2217 posts
Location
3232235883
Posted 16 May 2013 - 10:10 AM
yes, its correct, but you dont need that ? after it, thats for the GET parimeter
767 posts
Posted 16 May 2013 - 11:05 AM
the textutils.encode is ONLY for the http.get. but thanks. will try the code :D/>
2088 posts
Location
South Africa
Posted 16 May 2013 - 12:11 PM
You were missing an & which SadKingBilly got correct
169 posts
Posted 16 May 2013 - 12:19 PM
the textutils.encode is ONLY for the http.get. but thanks. will try the code :D/>
The pastebin program disagrees with you:
local response = http.post("http://pastebin.com/api/api_post.php", "api_option=paste&".."api_dev_key="..key.."&".."api_paste_format=lua&".."api_paste_name="..textutils.urlEncode(sName).."&".."api_paste_code="..textutils.urlEncode(sText))
You may have to to use urlEncode(), depending on the content of your variables. Whether it's a POST or GET, a random ampersand can still confuse the script and quotation marks can cause syntax errors if not escaped (by urlEncode()). The only thing strictly incorrect about my post was that I kept the "?" in there. Granted, you had it there, so I still can't be sure whether you're looking to do a POST or GET.
767 posts
Posted 16 May 2013 - 03:58 PM
Hmm. but. the code is working fine, but the webpage is erroring out… hmm whats wrong.. i know its a bit away from lua, but if someone knows how to fix, it then please tell me :D/>/>
Error:
Parse error: syntax error, unexpected T_STRING in /home/a1652713/public_html/lockP.php on line 4Spoiler
<!--?php
$key = 'not official';
$mysql = array();
$mysql['host'] = 'not official';
$mysql['username'] = 'not official';
$mysql['password'] = 'not official';
$mysql['database'] = 'not official';
$mysql['table'] = 'not official';
if(isset($_POST['key'])) {
$userKey = $_POST['key'];
if ($userKey == $key) {
$key = $_POST['licensekey'];
$con = mysql_connect($mysql['host'],$mysql['username'],$mysql['password']) or die(mysql_error());
$mysql_select_db($mysql['database'], $con) or die(mysql_error());
$query = "select * from 'not official' where license_key='$key'";
$result = mysql_query($query,$con) or die(mysql_error());
if (!$result || mysql_num_rows($result) < 1) { // checks to see if it's a valid key
echo 'Invalid License Key!';
} else {
$res = mysql_query("UPDATE 'not official' SET locked='true' WHERE license_key='$key' AND locked='false'", $con) or die(mysql_error());
}
} else {
echo '<h3-->Invalid access.';
}
}
?>
Thanks :D/>/>