Exchanging data between a PB app & a html-form

For everything that's not in any way related to PureBasic. General chat etc...
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Exchanging data between a PB app & a html-form

Post by merendo »

Hi everyone

Well, topic should tell most: I have a HTML-form. Like this:

Code: Select all

<html><body><form action="exec.php" method="POST">Type your name: <input type="text" name="name"><br><input type="submit" value="Say hello to you..."></form></body></html>
Okay, this is just a little example, the form I am working with is a bit bigger, but very similiar.

On another hand (On my third :twisted:) I got a PB-app which figures out the systems IP-Address.

Now my question. Is there a way to let the PB-app enter the IP-Address into a hidden <input>-field in the form? Maybe with some JavaScript?

I am not trying to code some virtual web-based spyware, don't worry :twisted:

Thanks for any help!! merendo
The truth is never confined to a single number - especially scientific truth!
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Code: Select all

<form action="mypbconsoleapp.exe" method="POST">
And, from your PB console app, retrieve the data using GetStdHandle_(#STD_INPUT_HANDLE), SetConsoleMode_() and ReadFile_(), or GetEnvironmentVariable_("QUERY STRING"...).

If you want to put the ip in a hidden input, just output the html page from your app, using GetStdHandle_(#STD_OUTPUT...) and WriteFile_().

Hope it helps,

Regards,
El_Choni
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Post by merendo »

Please correct me if I didn't get you right: Let the app itself be the webserver?
The truth is never confined to a single number - especially scientific truth!
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

I thought your app was meant to be a cgi app... Could you explain a bit more what you're trying to achieve?
El_Choni
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: Exchanging data between a PB app & a html-form

Post by NoahPhense »

Code: Select all

<html><body><form action="exec.php" method="POST">Type your name: <input type="text" name="name"><br><input type="submit" value="Say hello to you..."></form></body></html>
Well I have everything you need to create cgi. I used to create cgi with
VB and I still have all that code. If you are into a project that would be
for all, or for sale, or benefit everyone? Then you might want to convert
the vb code and have at it.

But, if this is for personal, I recommend just using php really.

Code: Select all

<? 
$time = date("l F dS h:i:s A Y"); //get time 
$ipaddress = "iplog.txt"; //define the file 
$do = fopen($ipaddress, 'a+'); //open file for editing 
fputs($do, "$REMOTE_ADDR | $time \n"); //write the file 
fclose($do); //finish 
?> 
I would place this code in the page that gets displayed AFTER the user
submits.

Change the file path to some dir that is protected.

- np

See what you did, you made me break out my webserver.. ;)
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Post by merendo »

@NoahPhense: It's a project for my school. Everytime the students log-in Windoze, a screen with a WebGadget appears. This screen is for registering the student, because the school must know when who was sitting on which computer. There is a close button in the right lower corner of the screen. But at first this button is disabled, only when the student has successfully registered, the button becomes enabled. And this is the problem: As the form is displayed in the Webgadget and the close button is part of the programme itsself, it's very hard to tell the programme when to enable the button.

I tried it this way: The app opens a little server. Now, when a student has successfully registered, the PHP-script on the schools server sends a little notification to the server which the app has opened. Thus the app knows 'Okay, now enable the button'. But '$REMOTE_ADDR' only returns the IP of the server, but not the IP of the machine which has sent the request.

So I am trying to write a PB app which reads the computer's ip and sent it somehow to the PHP-script on the server. But how?

I just don't understand why '$REMOTE_ADDR' just contains the IP of the server, but never the IP of the user.
The truth is never confined to a single number - especially scientific truth!
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

..

Post by NoahPhense »

Ok, let's start with a couple questions.

First, do you have access to the school servers?
Do you have access to the php running on the servers?

You mentioned "the PHP-script on the schools server sends a little
notification to the server which the app has opened"

What exactly is it sending? And when you say you are running a
'little server app' on the computers that the students are logging into
what does this little server app do?

--
The only thing that really needs to be done to log these students, is to
edit the .php file that contains this 'login form'. So that when the user
registers, it grabs his/her ip..

Last question for now. Where is this data going after its being grabbed
from the students computers?

- np
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Post by merendo »

Yes, I do have access to the server computer when my teacher is observing me. So I can configure everything if necessary. It's an Apache Web Server with PHP and MySQL installed.

The script just connects to the server to let him know 'the user has successfully registered.' After that, it emmediately disconnects, but it's enough for that purpose.

Well, that's the problem: How to grab the users IP? Usually I would use '$REMOTE_ADDR' for this, but this env_vari just doesn't contain what it should. It only contains the server IP but never the user IP - It's so strange. So I try to bypass this problem with a little PB app.

The data is stored in a MySQL table.
The truth is never confined to a single number - especially scientific truth!
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Try $_SERVER['REMOTE_ADDR']
El_Choni
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Why does this registration app need to use a browser controll?

Couldn't you just code the registration form in PB and submit to the server?

If you don't want to give the user access to the machine until they have registered, you could even make this a full screen app with no easy means of escape other than effectively registering.
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Post by merendo »

@GedB: The app must allow the user to close it only when the user has registered. And I have to bridge the gap between exe and html. This is possible via network.

@El_Choni: Thank you, I will try that. I can't try it out on my schools server until monday, but then (if I'm not too drunk :twisted:) I will try it and post here if it works. And if it doesn't... :wink:
The truth is never confined to a single number - especially scientific truth!
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

@GedB: The app must allow the user to close it only when the user has registered. And I have to bridge the gap between exe and html. This is possible via network.
Does the app sit there, annoying the user until they fill it in. Or does it fill the whole screen and refuse to let them use the computer until they have registered?
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Wait a second, I think I get it.

The purpose of the app is not to block access to Windows, but the web application.

They can use other windows applications, but not this web app.

Is that right?
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Post by merendo »

Err, no. :wink: The apps intention is to block access to any programme on that computer until the student has successfully registered. The school principal needs to know who was sitting when on which computer. This is if something gets damaged (soft or hardware) the student who has caused the trouble can be found out. This is why I don't want the students to be able to exit this app until the signed in.
The truth is never confined to a single number - especially scientific truth!
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

In that case you definately should be using an html form. There are just too many ways to circumvent the form. It should be a native application.

Using a Screen rather than a Window is a good idea, since this will stop access to the other windows. You'll also need to block all the control keys like CTRL-ALT-DELETE, etc.

After all this, you still won't be able to deny access to somebody who knows what they are doing.

You really need to move to an OS that requires login. What OS do they have at the moment?
Post Reply