Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Posting to PHP?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi how can I post to a regular PHP.

I've got a PHP script that is using a varialbe called: $data

I've got a SwingApplet, and I want to post my content to this PHP script. I've looked 4 it, but nothing found :-( *help

My JavaApplet cointains the Button:

void button_apply_actionPerformed(ActionEvent e) {

}

I importet the *.awt *.net etc. but nothing, I looked at Sun.java @ this Tutorial about posting, but it doesn't work :((

For any help ! THANX !
 
To get an applet to communicate with a server-side script, you have at least 2 options:
1) make the http call within Java. Your results will come back inside the applet, so you would have to process and display the results. Also note that applet security will prevent you from calling any other server than the one that served your applet, if it's an untrusted applet.
2) have your applet communicate with a form on the same page. The form can be hidden. The following excerpt is from an example I did a long time ago, but I checked it still works -
[tt]
<SCRIPT LANGUAGE=&quot;JavaScript1.1&quot;>
function getData() {
var val1 = document.enterNames.NamesToForm()
document.forms[0].FormEntry1.value = val1
}

function sendData() {
var val1 = &quot;init&quot;
val1 = document.forms[0].FormEntry1.value
document.enterNames.NamesToJava(val1)
}
</SCRIPT>

<BODY BGCOLOR=&quot;4040A0&quot; COLOR=&quot;FFFFFF&quot;>
Click the getData and sendData buttons. Yee-haw.
<HR>
<APPLET CODE=&quot;NameEntry&quot; NAME=&quot;enterNames&quot; WIDTH=200 HEIGHT=140>
</APPLET>

<FORM NAME=&quot;NameForm&quot;>
<INPUT TYPE=&quot;text&quot; VALUE=&quot;send this!&quot; NAME=&quot;FormEntry1&quot;>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;Get Data&quot; onClick=&quot;getData()&quot;>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;Send Data&quot; onClick=&quot;sendData()&quot;>
</FORM>
[/tt]

Note the applet, NameEntry.class, provides 2 methods: NamesToForm() and NamesToJava(var).

Don't know if that's the approach you want to take, but hope it helps.

-John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top