$_POST problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ramonypp
Forum Newbie
Posts: 2
Joined: Sat Feb 26, 2011 3:01 pm

$_POST problem

Post by ramonypp »

I wrote this code ;
<?php
$one = $_POST['one'];
$two= $_POST['one'];
$op= $_POST['sum'];

if($op=="sum")
{
print $one;
print $two;
print $one+$two;
}
?>
my problem is when i started the browser, $one and $two shown normally, but $one+$two shown zero,0
why is it so? anyone to help me?
ramonypp
Forum Newbie
Posts: 2
Joined: Sat Feb 26, 2011 3:01 pm

Re: $_POST problem

Post by ramonypp »

i found out, variables are type of string, although i casted to int them, no change happend
Note: I get the values from Flash
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: $_POST problem

Post by social_experiment »

ramonypp wrote:i found out, variables are type of string, although i casted to int them, no change happend
All form input are string.
ramonypp wrote:my problem is when i started the browser, $one and $two shown normally, but $one+$two shown zero,0
Could you paste the form code too. Not sure if you made a typo here, but your $two variable is also assigned the value of $_POST['one'].
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply