• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Giữ nguyên giá trị khi gửi form php - keep form values after post php

Admin

Well-Known Member
Staff member
Administrator
Chào bạn, hôm nay tuoitreit.vn xin hướng dẫn các bạn cách gửi form php giữ nguyên giá trị
Để làm được điều này bạn sử dụng code sau:
PHP:
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">

Giá trị a:<br> <input type="text" maxlength="3" name="a" placeholder="1" value="<?php echo  $_POST["a"]; ?>"><br>
Giá trị b:<br> <input type="text" maxlength="3" name="b" placeholder="2" value="<?php echo  $_POST["b"]; ?>"><br>
Giá trị c:<br> <input type="text" maxlength="3" name="c" placeholder="3" value="<?php echo  $_POST["c"]; ?>"><br>
<input type="submit" value="Tính" />
</form>
<?php

$a = floatval($_POST['a']);
$b = floatval($_POST['b']);
$c = floatval($_POST['c']);
echo "Tổng a + b + c là ".($a+$b+$c);

?>

Mọi thắc mắc vui lòng phản hồi bên dưới
Chúc bạn thành công!
Mọi sao chép vui lòng ghi rõ nguồn tuoitreit.vn!
 

Facebook Comments

Similar threads

New posts New threads New resources

Back
Top