-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertConfig.php
More file actions
41 lines (30 loc) · 1.08 KB
/
Copy pathinsertConfig.php
File metadata and controls
41 lines (30 loc) · 1.08 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
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'diario';
try{
$pdo = new PDO("mysql:host={$host};dbname={$db}", $user,$pass);
}
catch(PDOException $ex){
echo $ex -> getMessage();
}
if(isset($_GET['ID']) && $_GET['ID'] != ''){
$stmt = $pdo -> prepare('UPDATE noticia SET Titulo = :titulo, Copete = :copete, Imagen = :imagen, Texto = :texto, Autor = :autor WHERE ID = :id');
$stmt -> bindParam(':id', $_GET['ID']);
}else{
$stmt = $pdo -> prepare('INSERT INTO noticia(Titulo, Copete, Imagen, Texto, Autor) VALUES (:titulo, :copete, :imagen, :texto, :autor)');
}
$titulo = $_GET['titulo'];
$copete = $_GET['copete'];
$imagen = $_GET['imagen'];
$texto = $_GET['texto'];
$autor = $_GET['autor'];
$stmt -> bindParam(':titulo',$titulo);
$stmt -> bindParam(':copete',$copete);
$stmt -> bindParam(':imagen',$imagen);
$stmt -> bindParam(':texto',$texto);
$stmt -> bindParam(':autor',$autor);
$stmt -> execute();
header('location: index.html');
?>