Welcome visitor
* Login
* Register
It is currently March 25th, 2019, 2:15 pm
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Server Side » PHP



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  add items of a form
PostPosted: May 5th, 2009, 5:46 pm 
User avatar

Posts: 42
Hey, i have a form submitted to the server and im trying to know how to add the value of two fields or more? Thank you.


Top
 Profile  
 
  Re: add items of a form
PostPosted: May 5th, 2009, 6:51 pm 
User avatar

Posts: 86
PHP is like a "general-purpose" language for websites, it can add, substract, "print", connect to databases, etc. HTML, on the other hand, is only a "markup language" which means is only about using text.

When HTML sends a form to PHP, PHP gets it as variables inside an array (a set of variables). So, in PHP it would be as easy as
<?php
$result = $_POST['field1'] + $_POST['field2'];
//field1 and field2 should be the names of your fields
//$_POST is the array in which your form values are wrapped in
//check out the differences between POST and GET methods
echo $result;
?>

While on HTML alone it would be impposible to do.

Check out some tutorials to become more acquainted with PHP functions and logic, and you'll see how useful and easy to use language it is.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Server Side » PHP


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron