Evitar ingresar registros duplicados
Publicado por Nestor (2 intervenciones) el 28/12/2019 10:16:15
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 include ("db.php");
$conn = conn();
if(!$conn){
header('Location:error.php');
}
function cleanData($data){
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
//Los Datos
if(isset($_POST['formClient'])){
$namefull = cleanData($_POST['namefull']);
$direccion = cleanData($_POST['direccion']);
$phone = cleanData($_POST['phone']);
$email = cleanData($_POST['email']);
$city = cleanData($_POST['city']);
if(empty($namefull) or empty($direccion) or empty($email) or empty($phone) or empty($city)) {
header('Location:../include/error.php');
}
else{
$statement = $conn->prepare('INSERT INTO client(id,namefull,direccion,email,phone,city) VALUES ( NULL,:namefull,:direccion,:email,:phone,:city)');
$statement->execute(array(':namefull' => $namefull, 'direccion' => $direccion, 'email' => $email, ':phone' => $phone, 'city' => $city));
Creo que acá tendría que poner el código
Que compare la columna $namefull,
if ($statement){
$_SESSION['message'] = 'Paciente agregado con éxito <br><p class"cerrar-x">Cerrar</p>';
header('Location:../');
}else{
header('Location:../include/error.php');
}
}
}
?>
Valora esta pregunta


1