-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnew.php
More file actions
39 lines (28 loc) · 1.09 KB
/
new.php
File metadata and controls
39 lines (28 loc) · 1.09 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
<?php
include_once('config.php');
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$errors = validate(array('firstname', 'lastname', 'phone'), $_POST);
if(count($errors) == 0)
{
$db = @mysql_connect($database['host'], $database['username'], $database['password']) or die('Can\'t connect do database');
@mysql_select_db($database['name']) or die('The database selected does not exists');
$query = sprintf("INSERT INTO contacts (firstname, lastname, phone, mobile) VALUES ('%s', '%s', '%s', '%s')",
mysql_real_escape_string($_POST['firstname']),
mysql_real_escape_string($_POST['lastname']),
mysql_real_escape_string($_POST['phone']),
mysql_real_escape_string($_POST['mobile'])
);
$rs = mysql_query($query);
if (!$rs)
{
die_with_error(mysql_error(), $query);
}
mysql_close($db);
header('Location: index.php');
}
}
?>
<?php include_once('header.php') ?>
<?php include_once('_form.php') ?>
<?php include_once('footer.php') ?>