What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Check for input and post to PHP

Check for input and post to PHP
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Check for input and post to PHP
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.
  1. Make a function for your window's CtrlClicked event:
    code:
    function OnWindowIdEvent_CtrlClicked(PlusWnd, CtrlId) {
       ...
    }
  2. In that function, check if the CtrlId matches the ID of your submit button.
  3. 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");
  4. 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!
       ...
    }
  5. 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! (y)

This post was edited on 06-10-2008 at 02:29 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-10-2008 02:26 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Check for input and post to PHP - by r3m!xXx on 06-10-2008 at 02:07 PM
RE: Check for input and post to PHP - by matty on 06-10-2008 at 02:10 PM
RE: Check for input and post to PHP - by r3m!xXx on 06-10-2008 at 02:17 PM
RE: Check for input and post to PHP - by Volv on 06-10-2008 at 02:21 PM
RE: RE: Check for input and post to PHP - by r3m!xXx on 06-10-2008 at 02:26 PM
RE: Check for input and post to PHP - by Matti on 06-10-2008 at 02:26 PM
RE: Check for input and post to PHP - by r3m!xXx on 06-10-2008 at 02:45 PM
RE: Check for input and post to PHP - by Felu on 06-10-2008 at 02:49 PM
RE: RE: Check for input and post to PHP - by Volv on 06-10-2008 at 03:03 PM
RE: Check for input and post to PHP - by r3m!xXx on 06-10-2008 at 02:54 PM
RE: Check for input and post to PHP - by Felu on 06-10-2008 at 03:06 PM
RE: Check for input and post to PHP - by r3m!xXx on 06-10-2008 at 03:37 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On