Sending data to online forms |
Author: |
Message: |
absorbation
Elite Member
Posts: 3636 Reputation: 81
– / /
Joined: Feb 2005
|
O.P. Sending data to online forms
Now, I am creating something, something special, but I have run into a spot of bother. I want to send data from a Plus! script to a form online, which will then add data to a database. Problem is, this is something I really do not understand and I want it secure. I am confused about sending data from a script into <input> fields online. So if anyone has any basic examples or any tips to make sure it is secure it would really help .
Thanks .
|
|
07-24-2006 11:22 AM |
|
|
-dt-
Scripting Contest Winner
;o
Posts: 1819 Reputation: 74
36 / /
Joined: Mar 2004
|
|
07-24-2006 11:27 AM |
|
|
Ezra
Veteran Member
Forgiveness is between them and God
Posts: 1960 Reputation: 31
37 / /
Joined: Mar 2003
|
RE: Sending data to online forms
You can't send the data to <input> fields, you have to send it to the php whatever script directly, using preferably POST.
code: var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open ("POST", postaddress, true);
http.send (postdata);
Something like that.
Securing it, could only be done by using SSL, but you need a server that can handle SSL traffic.
This post was edited on 07-24-2006 at 11:36 AM by Ezra.
|
|
07-24-2006 11:27 AM |
|
|
absorbation
Elite Member
Posts: 3636 Reputation: 81
– / /
Joined: Feb 2005
|
O.P. RE: Sending data to online forms
Well Ezra, a real example would help a lot, just something to point to a script online and send a PostAddress variable to it. I then can work my way into things by myself .
|
|
07-24-2006 11:40 AM |
|
|
Ezra
Veteran Member
Forgiveness is between them and God
Posts: 1960 Reputation: 31
37 / /
Joined: Mar 2003
|
RE: Sending data to online forms
Well, that one kinda worked already...
code: var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open ("POST", "http://www.absorbation.com/script.php", true);
http.send ("The data you want to sent...");
That can be retrieved with the php GET_RAW_POST_DATA function.
code: var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open ("POST", "http://www.absorbation.com/script.php", true);
http.send ("?name=absorbation&status=online");
This can be retrieved simply by using $_POST['name'] and $_POST['status']
EDIT:
http://www.w3schools.com/ajax/ajax... Also read that, tells you about the xmlhttprequest functions
This post was edited on 07-24-2006 at 11:48 AM by Ezra.
|
|
07-24-2006 11:46 AM |
|
|
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
Joined: Oct 2003
|
RE: Sending data to online forms
quote: Originally posted by Ezra
code: var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open ("POST", "http://www.absorbation.com/script.php", true);
http.send ("?name=absorbation&status=online");
That snippet seems to bear more resemblance to a GET request, where vars are in the URL.
|
|
07-24-2006 12:05 PM |
|
|
absorbation
Elite Member
Posts: 3636 Reputation: 81
– / /
Joined: Feb 2005
|
O.P. RE: Sending data to online forms
I am having some slight trouble, what is wrong here?
My index.php file: ($con varible is missing for obvious reasons)
code: $value= mysql_real_escape_string($_POST['value']);
mysql_query("insert into personalmessages values('','1','$value','time')");
mysql_close($con);
And my script code:
code: function OnEvent_MyPsmChange(NewPsm)
{
var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open ("POST", "http://bananaphone.absorbation.com/index.php", true);
http.send ("?username=absorbation?password=password?feild=psm?value=testing");
}
I know it is sending something, as every time I change my personal message the database has a value added to it. The problem is, it is not adding the $value variable, any ideas why?
|
|
07-24-2006 12:06 PM |
|
|
Dempsey
Scripting Contest Winner
http://AdamDempsey.net
Posts: 2395 Reputation: 53
38 / /
Joined: Jul 2003
|
RE: Sending data to online forms
quote: Originally posted by absorbation
I know it is sending something, as every time I change my personal message the database has a value added to it. The problem is, it is not adding the $value variable, any ideas why?
Could it be because you have
http.send ("?username=absorbation?password=password? feild=psm?value=testing");
And the script is expecting field?
|
|
07-24-2006 12:11 PM |
|
|
Ezra
Veteran Member
Forgiveness is between them and God
Posts: 1960 Reputation: 31
37 / /
Joined: Mar 2003
|
RE: Sending data to online forms
quote: Originally posted by absorbation
code: function OnEvent_MyPsmChange(NewPsm)
{
var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open ("POST", "http://bananaphone.absorbation.com/index.php", true);
http.send ("?username=absorbation?password=password?feild=psm?value=testing");
}
Only the first variable should have a question mark the next should have an ampersand
code: ?username=absorbation&password=password&feild=psm&value=testing
EDIT: searching a little about it, I don't think you need that first questionmark.
code: username=absorbation&password=password&feild=psm&value=testing
Should do the trick
This post was edited on 07-24-2006 at 12:16 PM by Ezra.
|
|
07-24-2006 12:13 PM |
|
|
absorbation
Elite Member
Posts: 3636 Reputation: 81
– / /
Joined: Feb 2005
|
O.P. RE: Sending data to online forms
quote: Originally posted by Dempsey
Could it be because you have
http.send ("?username=absorbation?password=password?feild=psm?value=testing");
And the script is expecting field?
Nope, I am not currently using that variable, what I have posted is the whole of my code, apart from the $con variable. I am just trying to receive the $value variable at the moment .
quote: Originally posted by Ezra
Only the first variable should have a question mark the next should have an ampersand
Still not picking it up :
code: http.send ("?username=absorbation&password=password&feild=psm&value=testing");
And your question mark idea still does not pick up the variable. I am beginning to think it is a problem with index.php?
This post was edited on 07-24-2006 at 12:21 PM by absorbation.
|
|
07-24-2006 12:15 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|