forked from snehshrivastava/Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject1_teachersform.php
More file actions
68 lines (63 loc) · 2.82 KB
/
project1_teachersform.php
File metadata and controls
68 lines (63 loc) · 2.82 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
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
$nameErr=$emailErr=$websiteErr=$genderErr="";
$name=$email=$information=$website=$speciality="";
if($_SERVER["REQUEST METHOD"]=="POST") {
if(empty($_POST["name"])) {
$nameErr="Name is REQUIRED";
}
else {
$name=test_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr="Only letters and blank spaces allowed";
}
}
if(empty($_POST["email"])) {
$emailErr="Email is required";
}
else {
$email=test_input($_POST["email"]);
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr="Invalid email format";
}
}
if(empty($_POST["website"])) {
$website="";
}
else {
$website = test_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website) {
$websiteErr="Invalid Url";
}
}
}
<form method="post" action = "<?php echo htmlspecialchars ($_SERVER["PHP_SELF"]);?>">
Name: <input type = "text" name = "name" value = "<?php echo $name; ?>">//first time without error checking
<br><br>
Email:<input type = "text" name = "email" value = "<?php echo $email; ?>">
<br><br>
Information: <textarea name = " information" rows = "5" cols = "40" >
<?php echo $information ?></textarea>
<br><br>
Website from where someone can come to know about you: <input type = "text" name = "website" value = "<?php echo $website; ?>">
<br><br>
Your Speciality: <input type = "text" name = "speciality" value = "<?php echo $speciality; ?>">
<br><br>
Gender:
<input type = "radio" name = "gender" <?php if (isset($gender) && $gender=="female") echo "checked"; ?> value = "female">Female
<input type = "radio" name = "gender" <?php if (isset($gender) && $gender=="male") echo "checked"; ?> value = "male">Male
<br><br>
Password: <input type = "text" name = "password" value = "<?php echo $password; ?>">
<br><br>
Enter Password Again: <input type = "text" name = "pass_again" value = "<?php echo $pass_again; ?>">
<br><br>
</form>
</body>
</html>