Wednesday, 15 June 2011

php - I can't get a value in my variable -



php - I can't get a value in my variable -

<html> <head> <title>panier</title> <?php $tot = 'test'; $m1 = $_post['montant1']; ?> </head> <body> <h1>panier</h1> <table border=1> <form action="panier.php" method="post"> <tr><td>produit</td><td>quantite</td><td>prix unitaire</td><td>action</td><tr> <tr><td>produit 1</td><td><input type='text' name='montant1' value='2'></form></td><td>3.19</td><td><a href=>supprimer</a></tr> </form> </table> </body> </html>

for reason variable $m1 can't what's within input textfield 'montant1'

i have noticed have not added submit button form, there no way of pushing info forward! add together after text input tag (in form).

<input type="submit" value="submit form">

assuming posting same page. replace php code this:

<?php if($_post){ $tot = 'test'; $m1 = $_post['montant1']; } ?>

this way handle info if there.

also, recommended set $_server['php_self'] instead of page name if posting on same page. way, wouldn't have handle code changes if rename file.

<form action="<?php echo $_server['php_self']; ?>" method="post">

php

No comments:

Post a Comment