Yes, that thread will help you out with most of your problems about sending the information. Checking for emptiness isn't that hard either.
Here's some kind of scheme which you should base your code on.
- Make a function for your window's CtrlClicked event:
code:
function OnWindowIdEvent_CtrlClicked(PlusWnd, CtrlId) {
...
}
- In that function, check if the CtrlId matches the ID of your submit button.
- If it matches, we'll firstly have to get the three text inputs:
code:
var t1 = PlusWnd.GetControlText("text1");
var t2 = PlusWnd.GetControlText("text2");
var t3 = PlusWnd.GetControlText("text3");
- Then, we'll check the emptiness:
code:
if(t1 == "" || t2 == "" || t3 == "") {
//Show an error message.
//For more information, check the MSDN page of MessageBox.
//http://msdn.microsoft.com/en-us/library/ms645505.aspx
Interop.Call("user32", "MessageBoxW", 0, "A required field has been left empty.\nPlease check your inputs and try again.", "Field left empty", /* MB_ICONEXCLAMATION */ 0x30);
} else {
//Input is valid, send the information to the PHP page!
...
}
- If it's not empty, the information can be sent to the PHP page by using the method explained in [Tutorial] Communicating with web pages. Depending of how your PHP page wants to receive the information, you can either send it using GET or POST. The tutorial explains it very well, I'm sure you'll find out what you have to do.
Yes, the error stuff can be done with a call to MessageBox.
(The W after the function's name indicates that the Unicode version should be used, it's not a typo!)
quote:
Originally posted by Volv
You could also/alternatively add a check in your PHP code:
code:
if ($_POST['t1'] == "") {
// error
} else {
// continue
}
You should have that code in your PHP anyway to prevent malicious attacks, but a check in the script itself is more useful because you can get a nice error box before any data is transmitted. I recommend using both for the best experience for both you and the users!