forked from ashu11939/CSI_Webd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonline_form.php
55 lines (43 loc) · 1.26 KB
/
online_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
<?php
$connect = mysql_connect("localhost","root","");
if(!$connect) die ("connection not established".mysql_error());
mysql_select_db("forms",$connect);
function testinput($data)
{
$data = stripslashes($data);
$data = htmlspecialchars($data);
$data = trim($data);
return $data;
}
if($_SERVER['REQUEST METHOD'] == "POST")
{
$firstname = testinput($_POST['$firstname']);
$lastname = testinput($_POST['$lastname']);
$currentyear = testinput($_POST['$currentyear']);
$email = testinput($_POST['$email']);
$contact = testinput($_POST['tel']);
$yearsjoined = testinput($_POST['$yearsjoined']);
$fees = testinput($_POST['$fees']);
}
$_SESSION['firstname'] = $firstname;
$_SESSION['lasttname'] = $lasttname;
$name = $_SESSION['firstname'] . "" . $_SESSION['firstname'];
if(!is_numeric($contact)) {header("location: fill_form.html?error=1");exit;}
//Update database
$query = "INSERT INTO form(name,currentyear,email,contact,yearsjoined,fees)
VALUES('$name','$currentyear','$email','$contact','$yearsjoined','$fees');";
$sql = mysql_query($query);
if(!$sql)
{
echo mysql_error();
exit;
}
mysql_close($connect);
header("location : index.html");
exit;
else
{
echo "Your response has been recorded";
header("location : index.html");
}
?>