Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
66 lines (53 loc) · 1.54 KB

File metadata and controls

66 lines (53 loc) · 1.54 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<?php
$name_error = "";
$age_error = "";
$msg = "";
//check whether the value is coming from the right form
if(isset($_POST['submit']) && $_POST['submit'] = "save") {
//include basic crud file to access the class
include_once 'basic_crud.php';
//initialize basic crud class object
$crud_object = new Basic_CRUD();
//var_dump($_POST);
//check if both post values(name and age) are set
if( ($_POST['name']!="") && ($_POST['age'] !="") ) {
//this is used for inserting.
$result = $crud_object->insert_CRUD($_POST);
if ($result > 0) {
$msg = "Inserted new data succcessfully.";
header("Location:display.php?msg=".$msg);
}
}else {
//if name is empty set error
if($_POST['name']=="" || !isset($_POST['name'])) {
$name_error = "Name is required.";
}
//if age is empty set error
if($_POST['age']=="" || !isset($_POST['age'])) {
$age_error = "Age is required.";
}
}
}
?>
<html>
<head>
<title>INSERT OPERATION IN OOP</title>
</head>
<body>
<form name="insert_form" method="post" action="">
<table>
<tr>
<td><label>NAME: </label></td>
<td><input type="text" name="name" value="<?php if(isset($_POST['name'])) echo $_POST['name'];?>"/><?php if(isset($name_error)) echo $name_error;?></td>
</tr>
<tr>
<td><label>AGE: </label></td>
<td><input type="text" name="age" value="<?php if(isset($_POST['age'])) echo $_POST['age'];?>"/><?php if(isset($age_error)) echo $age_error;?></td>
</tr>
<tr>
<td colspan="2"><label><input type="submit" name="submit" value="Save"> </label></td>
</tr>
</table>
</form>
</body>
</html>
Morty Proxy This is a proxified and sanitized view of the page, visit original site.