-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7.php
More file actions
161 lines (113 loc) · 4.15 KB
/
Copy path7.php
File metadata and controls
161 lines (113 loc) · 4.15 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
class Form {
public function input($array){
return '<input ' . $this->createString($array) . '><br>';
}
public function submit($array){
return '<input type="submit" ' . $this->createString($array) . '><br>';
}
public function password($array){
return '<input type ="password" ' . $this->createString($array) . '><br>';
}
public function textarea($array){
return '<textarea ' . $this->createString($array) . '></textarea><br>';
}
public function open($array){
return '<form ' . $this->createString($array) . '><br>';
}
public function close(){
return '</form>';
}
private function createString($array){
$string = '';
foreach ($array as $key => $value) {
$string .= $key . ' = "' . $value . '" ';
}
return $string;
}
}
$form = new Form;
echo $form->open(['action'=>'', 'method'=>'POST']);
//Код выше выведет <form action="" method="POST">
echo $form->input(['type'=>'text', 'placeholder'=>"Ваше ім'я", 'name'=>'name']);
//Код выше выведет <input type="text" value="!!!">
echo $form->password(['value'=>'123', 'name'=>'pass']);
//Код выше выведет <input type="password" value="123">
echo $form->textarea(['placeholder'=>123, 'name'=>'textarea']);
//Код выше выведет <textarea placeholder="123"></textarea>
echo $form->submit(['value'=>'Відправити']);
//Код выше выведет <input type="submit" value="Відправити">
echo $form->close();
/*class SmartForm extends Form {
public function input($array){
if(!empty($_REQUEST['name'])){
$array['value'] = $_REQUEST['name'];
return parent::input($array);
} else {
return parent::input($array);
}
}
public function password($array){
if(!empty($_REQUEST['pass'])){
$array['value'] = $_REQUEST['pass'];
return parent::password($array);
} else {
return parent::password($array);
}
}
public function textarea($array){
if(!empty($_REQUEST['textarea'])){
$array['value'] = $_REQUEST['textarea'];
return parent::textarea($array);
} else {
return parent::textarea($array);
}
}
/*public function input ($array) {
if(isset($REQUEST['name'])) {
$value = $REQUEST['name'];
return parent::input($array). $value;
}
}
public function password ($array) {
if(isset($REQUEST['pass'])) {
$value = $REQUEST['pass'];
return parent::password($array). $value;
}
}
public function textarea ($array) {
if(isset($REQUEST['textarea'])) {
$value = $REQUEST['textarea'];
return parent::textarea($array). $value;
}
}
}
/*$form = new Form;
$smartForm = new smartForm;
echo $form->open(['action'=>'', 'method'=>'POST']);
//Код выше выведет <form action="" method="POST">
echo $smartForm->input(['type'=>'text', 'placeholder'=>"Ваше ім'я", 'name'=>'name']);
//Код выше выведет <input type="text" value="!!!">
echo $smartForm->password(['value'=>'123', 'name'=>'pass']);
//Код выше выведет <input type="password" value="123">
echo $smartForm->textarea(['placeholder'=>123, 'name'=>'textarea']);
//Код выше выведет <textarea placeholder="123"></textarea>
echo $form->submit(['value'=>'Відправити']);
//Код выше выведет <input type="submit" value="Відправити">
echo $form->close();*/
//Код выше выведет </form
?>
<!--
<form action="" method="GET">
<select name="age[]" size="7">
<option disabled>Сколько вам лет?</option>
<option value="менее 20 лет"> менее 20 лет</option>
<option value="20-25"> 20-25 </option>
<option value="26-30"> 26-30 </option>
<option value="более 30"> более 30 </option>
</select>
<input type="submit" name="Отправить">
</form>
<?php/*
foreach ($_GET['age'] as $key=>$value) echo "Вам ". $value . "<br>";*/
?>