-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.php
More file actions
49 lines (48 loc) · 1.72 KB
/
Copy pathadd.php
File metadata and controls
49 lines (48 loc) · 1.72 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
<?php
require 'config.php';
if(!empty($_POST)){
$title = $_POST['title'];
$description = $_POST['description'];
$stmt=$pdo->prepare("INSERT INTO posts(title,description) VALUES(:title, :description)");
$result=$stmt->execute(
array(
':title' => $title ,
'description' => $description
)
);
if($result){
echo "<script>alert('Added record is successfully');
window.location.href='index.php';
</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
</head>
<body>
<div class="card">
<div class="card-body">
<h1>Create News</h1>
<hr>
<form action="add.php" method="post">
<div class="form-group">
<label for="">Title</label>
<input type="text" name="title" class="form-control" required>
</div>
<div class="form-group">
<label for="">Description</label>
<textarea name="description" id="" cols="30" rows="10" class="form-control" required></textarea>
</div>
<button class="btn btn-primary">Add</button>
<a href="index.php" type="button" class="btn btn-warning">Back</a>
</form>
</div>
</div>
</body>
</html>