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

Pages: (2): « First [ 1 ] 2 » Last »
Check for input and post to PHP
Author: Message:
r3m!xXx
New Member
*


Posts: 6
Joined: Jun 2008
O.P. Check for input and post to PHP
first of all: hey! im teh new one!!11 8-|

i got a lil script knowledge issue:

imagine a window with 3 editable text inputs. text1, text2 and text3.
at the bottom i got a submit button.

what i dont know:

i need to check all of the 3 texts boxes for emptyness! if text1 empty -> error msg, else if text2 is empty msg -> error else if text 3 is empty -> error msg

if all of them are fillled with text, they should be put in a variable seperately. e.g. t1, t2 and t3, because i want to put them into a post script later for a mysql_query.

i guess this one would work with my idea: http://shoutbox.menthix.net/showthread.php?tid=82911

would be fine if someone could assist me.

EDIT: they dont need to be seperately at all :)

This post was edited on 06-10-2008 at 02:08 PM by r3m!xXx.
06-10-2008 02:07 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Check for input and post to PHP
Did you check the Scripting Documentation?

In there you will find that when they press the button you can use

code:
if ( pPlusWnd.GetControlText("Text1") === "" ) {
    // error
}
06-10-2008 02:10 PM
Profile E-Mail PM Find Quote Report
r3m!xXx
New Member
*


Posts: 6
Joined: Jun 2008
O.P. RE: Check for input and post to PHP
should have pointed it out clearlier, my problem is the error stuff. how do i prevent the script from writing unfilled stuff in my database?
06-10-2008 02:17 PM
Profile E-Mail PM Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
34 / Male / Flag
Joined: Oct 2004
RE: Check for input and post to PHP
quote:
Originally posted by r3m!xXx
should have pointed it out clearlier, my problem is the error stuff. how do i prevent the script from writing unfilled stuff in my database?
That is what matty's code does, it checks if the textbox is empty.
You could also/alternatively add a check in your PHP code:
code:
if ($_POST['t1'] == "") {
    // error
} else {
    // continue
}

This post was edited on 06-10-2008 at 02:23 PM by Volv.
06-10-2008 02:21 PM
Profile PM Find Quote Report
r3m!xXx
New Member
*


Posts: 6
Joined: Jun 2008
O.P. RE: RE: Check for input and post to PHP
quote:
Originally posted by Volv

That is what matty's code does, it checks if the textbox is empty.
You could also/alternatively add a check in your PHP code:
code:
if ($_POST['t1'] == "") {
    // error
} else {
    // continue
}


thats a good solution, i didnt even think that way around.
06-10-2008 02:26 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / 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
r3m!xXx
New Member
*


Posts: 6
Joined: Jun 2008
O.P. RE: Check for input and post to PHP
thx for ur huge help, but i didnt get point 2 and 3.

what does #2 actually make? could you give me a hint where i can find that in this documentation?
do i have to put #3 and #4 in the function u told me to make in #1?
06-10-2008 02:45 PM
Profile E-Mail PM Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
29 / Male / Flag
Joined: Apr 2006
Status: Away
RE: Check for input and post to PHP
code:
function OnWindowIdEvent_CtrlClicked(PlusWnd, CtrlId) {
   if(CtrlId == "BtnSubmit") { // Thats Point #2 to check whether its the submit button clicked. Replace BtnSubmit with whatever ID you've given to the submit button
    var t1 = PlusWnd.GetControlText("text1"); //Point #3
    var t2 = PlusWnd.GetControlText("text2");
    var t3 = PlusWnd.GetControlText("text3");
    //here goes the rest of the code....
   } // <3 Volv
}

This post was edited on 06-10-2008 at 03:05 PM by Felu.
06-10-2008 02:49 PM
Profile E-Mail PM Web Find Quote Report
r3m!xXx
New Member
*


Posts: 6
Joined: Jun 2008
O.P. RE: Check for input and post to PHP
aight, thats another huge help, thanks to you guys.
06-10-2008 02:54 PM
Profile E-Mail PM Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
34 / Male / Flag
Joined: Oct 2004
RE: RE: Check for input and post to PHP
quote:
Originally posted by Felu
code:
function OnWindowIdEvent_CtrlClicked(PlusWnd, CtrlId) {
   if(CtrlId == "BtnSubmit") { // Thats Point #2 to check whether its the submit button clicked. Replace BtnSubmit with whatever ID you've given to the submit button
    var t1 = PlusWnd.GetControlText("text1"); //Point #3
    var t2 = PlusWnd.GetControlText("text2");
    var t3 = PlusWnd.GetControlText("text3");
    //here goes the rest of the code....
}

You forgot to close your if()
06-10-2008 03:03 PM
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


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