-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.php
123 lines (110 loc) · 2.69 KB
/
form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!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=iso-8859-1" />
<title>Form</title>
<script type="text/javascript">
function valid()
{
var x=document.forms["frm"]["uname"].value;
if (x==null || x=="")
{
alert("Plz enter User Name");
return false;
}
var x=document.forms["frm"]["pass"].value;
if (x==null || x=="")
{
alert("Plz enter Password");
return false;
}
var x=document.forms["frm"]["add"].value;
if (x==null || x=="")
{
alert("Plz enter Address");
return false;
}
var x=document.forms["frm"]["color"].value;
if (x==null || x=="")
{
alert("Plz Select Color");
return false;
}
var x=document.forms["frm"]["hby"].value;
if (x==null || x=="")
{
alert("Plz Select Hobby");
return false;
}
}
</script>
</head>
<body><center><h3><strong>Form</strong></h3></center>
<form action="form.php" method="post" name="frm" onsubmit="return valid()">
<table align="center" border="1">
<tr>
<td>User Name</td>
<td><input type="text" name="uname" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass" /></td>
</tr>
<tr>
<td>Address</td>
<td><textarea rows="5" cols="15" name="add"></textarea></td>
</tr>
<tr>
<td>Gender</td>
<td><input type="radio" name="gender" value="M" />Male
<input type="radio" name="gender" value="F" />Female</td>
</tr>
<tr>
<td>Fev.Color</td>
<td><select name="color">
<option value="red" selected="selected">Red</option>
<option value="yellow">Yellow</option>
</select></td>
</tr>
<tr>
<td>Hobby</td>
<td><input type="checkbox" name="hby[]" value="Read" />Read
<input type="checkbox" name="hby[]" value="Internet" />Internet</td>
</tr>
<tr>
<td>Photo</td>
<td><input type="file" name="file" /></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" name="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
<?php
if(isset($_REQUEST['submit']))
{
$uname=$_POST['uname'];
$pass=$_POST['pass'];
$add=$_POST['add'];
$gen=$_POST['gender'];
$color=$_POST['color'];
$temp=$_POST['hby'];
if($temp)
{
$hby=implode(",",$temp);
}
echo "welcome:" . " " . $uname;
echo "<br/>";
echo "Password:" . " " . $pass;
echo "<br/>";
echo "Address:" . " " . $add;
echo "<br/>";
echo "Gender:" . " " . $gen;
echo "<br/>";
echo "Fev.Color:" . " " . $color;
echo "<br/>";
echo "Hobby:" . " " . $hby;
}
?>