PDA

View Full Version : check input box


snowedin
04-28-2002, 07:33 PM
Hi,

I can send the contents of an input box (var name=body)
to mysql via php - and return 'thanks!' if the db was updated.

But I want to prevent the 'thanks!' from being sent in as a post.

How do I check the contents of the body for that string?


send button code:

on (release) {

check = "thanks!";
if (body == check) { body=""; } - doesn't work

// if (body == "thanks!") {body=""; } -doesn't work either


if (body !="") {loadVariablesNum("add.php", 0, "POST");
} //works fine

}


thanks,
s.

Ricod
04-29-2002, 12:36 PM
did u trace it ? trace(body); and then test to see what body's value is.

snowedin
04-29-2002, 04:43 PM
How do I open the output window when the swf is embedded in html?

It needs to be in html for php/mysql connection.

trace doesn't seem to output unless it's in MX test mode or standalone player - but then backend doesn't connect.

btw- I also tried url-encoding on the return message.

thanks,
s.

snowedin
04-29-2002, 04:46 PM
How do I open the output window when the swf is embedded in html?

It needs to be in html for php/mysql connection.

trace doesn't seem to output unless it's in MX test mode or standalone player - but then backend doesn't connect.

Perhaps I don't understand trace() - trace(body) should print to the output window, yes?


(btw- I also tried url-encoding on the return message. )

thanks,
s.

Ricod
05-01-2002, 09:11 AM
What is the path to body ? I don't think its in the button right ? Try using the absolute path to 'body'. if body != "" will always work I believe. (I'm wondering here what'll happen if you change the if state to : if != NULL)

snowedin
05-02-2002, 03:55 AM
The body field is being accessed fine or this wouldn't work, yes?
(it's in the same frame and layer as the button)

if (body !="") {loadVariablesNum("add.php", 0, "POST");
} //works fine

Checking to see if body is empty always works.

The problem seems to be checking the contents of body against a string that I don't want to send, and then clearing that string...

if (body == "thanks!") {body=""; } //doesn't work

I also tried :

on (press) { if (body == "thanks!") body=""; }

on (release) {
if (body !="") loadVariablesNum("add.php", 0, "POST");
}


Same result - it lets 'thanks!' get through.

I probably have to do my checks in a different frame?

anyhow, thanks,
s.

Ricod
05-02-2002, 12:15 PM
No, you see 'body' is always null, since there is no variable 'body' in the button.

Let's say the variable 'body' is on the main timeline, and so's the button. _root.body would check it. Use that in the if statement as well ... You see, if _root.body = "thanks !", the 'body' inside the button still isn't ""(<- is empty string), but null (<- nothing);

Use the absolute path to make sure its this.

snowedin
05-02-2002, 05:21 PM
Actually figured it out by using telnet to check the database for the actual contents of the string in question...... and it was adding an extra space at the end of the string.

After adjustment to php, rawurlencode the string but not the var name - problem solved!

(I didn't need to use root path.)

But thanks, Ricod, for all your responses.

s.