Thứ Hai, 13 tháng 5, 2013

Bài tập thực hành về isset

Bài 1: Form 1

File 1: nhapvao3

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test 3</title>
</head>
<form action="nhandulieu3.php" method="post">
    <label for="txt_hoten">Ho ten</label>
    <input type="text" id="txt_hoten" name="txt_hoten" />
    <br/>
    <label>Gioi tinh</label>
    <input type="radio" name="rd_sex" id="rd_nam" value="Nam"/> <label>Nam</label>
    <input type="radio" name="rd_sex" id="rd_nu" value="Nu" /> <label>Nu</label>
    <br/>
    <label>Nghe nghiep</label>
    <select name="sl_job" >
    <option id="sv">Sinh vien</option>
        <option id="hs">Hoc sinh</option>
    </select>
    <br/>
    <label for="cmt_noidung">Noi dung</label>
    <textarea name="cmt_noidung" id="cmt_noidung" cols="10" rows="5">
    </textarea>
    <br/>
    <label>Cach gui</label>
    <input type="checkbox" name="ch_gui" id="ch_gui" /> <label for="ch_gui">Email</label>

       
   
    <br/>
    <input type="submit" value="Gui di" />
    <input type="reset" value="Lam lai"  />
   
    </form>
<body>
</body>
</html>

File 2: nhandulieu3.php


<?php
$hoten=0;
$gioitinh=0;
$nghenghiep=0;
$thongtin=0;
$cachgui=0;

if(isset($_POST["txt_hoten"]) && $_POST["rd_sex"] && $_POST["sl_job"] && $_POST["cmt_noidung"] && $_POST["ch_gui"])
{
$hoten=$_POST["txt_hoten"];
$gioitinh=$_POST["rd_sex"];
$nghenghiep=$_POST["sl_job"];
$thongtin=$_POST["cmt_noidung"];
$cachgui=$_POST["ch_gui"];
}
echo $hoten;
echo "<br/>";
echo $gioitinh;
echo "<br/>";
echo $nghenghiep;
echo "<br/>";
echo $thongtin;
echo "<br/>";
echo $cachgui;


?>



Không có nhận xét nào:

Đăng nhận xét