PDA

View Full Version : ODD $_POST Results


Eth
07-29-2008, 05:46 AM
I am making a Flash/PHP form, the text inputs are of type input and I am using $_POST method on a server, not local. When I press the button, the variables are sent but what the results obtained in PHP is the code for the input text box such as...

<?php

//File being written to
$filename = "triple_rlc_result.CKT";

//Get capacitors
$c1 = $_POST['c1'];
$c2 = $_POST['c2'];
$c3 = $_POST['c3'];

//Open file
$fo = fopen( $filename, 'w' ) or die( "Unable to open file." );

//Write title
$string = "*Writing to the filename, " . $filename . " \r\n";
fwrite( $fo, $string );

//Write capacitors
$string = "C1 7 0 " . $c1 . "P\r\n";
fwrite( $fo, $string );
$string = "C1 6 0 " . $c2 . "P\r\n";
fwrite( $fo, $string );
$string = "C1 5 0 " . $c3 . "P\r\n";
fwrite( $fo, $string );

fclose( $fo );

?>

The output file looks like this...

*Writing to the filename, triple_rlc_result.CKT
C1 7 0 <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Times New Roman\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">10</FONT></P></TEXTFORMAT>P
C1 6 0 <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Times New Roman\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">10</FONT></P></TEXTFORMAT>P
C1 5 0 <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Times New Roman\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">10</FONT></P></TEXTFORMAT>P

So $c1 = <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Times New Roman\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">10</FONT></P></TEXTFORMAT>P ???

What is going on here? Any thoughts? Thanks

evride
07-29-2008, 06:20 AM
um. when declaring the variables to send, make sure to you use the text property of the textInput.

var urlVars:URLVariables = new URLVariables();
urlVars.dude = txtinput1.text;
urlVars.dudemeister = txtinput2.text;

Eth
07-29-2008, 08:15 AM
Here is my code for sending to the php file...

submit_btn.onRelease = function( )
{
var loginVars:LoadVars = new LoadVars();
loginVars.c1 = Number( form.c1.text );
loginVars.c2 = Number( form.c2.text );
loginVars.c3 = Number( form.c3.text );
loginVars.l1 = Number( form.l1.text );
loginVars.l2 = Number( form.l2.text );
loginVars.l3 = Number( form.l3.text );
loginVars.r1 = Number( form.l1.text );
loginVars.r2 = Number( form.l2.text );
loginVars.r3 = Number( form.l3.text );
loginVars.sendAndLoad("triple_rlc.php", loginVars, "POST");
};

Now I'm getting the result of NaN and without the Number( ) function; I am getting undefined results. Any ideas why is going on? I have real interger values set at default. So there are values for the variables in the Flash form.

Canazza
07-29-2008, 09:25 AM
try parseInt() or parseFloat() instead of Number()