Hola a todos, tengo una duda estoy tratande insertar datos a la db, pero no lo estoy haciendo utilizando desde el mismo archivo y la verdad no se bien como hacerlo o que falta a lo que estoy haciendo.
Este es el primer archivo:
prueba.php
Código:
<?php
try {
$con = new PDO('mysql:host=localhost;dbname=db','root',pass');
}
catch (PDOException $e){
echo 'Failed to get DB handle: '.$e->getMessage().'';
exit;
}
$buc = $con->query("SELECT * FROM butter");
$fila = $sql->fetch();
$me = "seva";
$blde = 1;
?>
<a href="classe/abm.php?<?=$fila['id'];?><?=$fila['user'];?>">add</a>
este es el otro:
abm.php
Código:
<?php
try {
$con = new PDO('mysql:host=localhost;dbname=db','root',pass');
}
catch (PDOException $e){
echo 'Failed to get DB handle: '.$e->getMessage().'';
exit;
}
$add = "INSERT INTO butter(shotid, me, blde, usershot) VALUES (:shotid, :me, :blde, :usershot)";
$stmt = $con->prepare($add);
$stmt->bindValue(':shotid',$_POST['id'], PDO::PARAM_STR);
$stmt->bindValue(':me', $me);
$stmt->bindValue(':blde', $blde);
$stmt->bindValue(':usershot', $_POST['user'], PDO::PARAM_STR);
$stmt->execute();
?>
el error que me da es:
Notice: Undefined index: id in...
Notice: Undefined variable: me in...
Notice: Undefined variable: blde in...
Notice: Undefined index: user in...
pero no se si esta bien usado $_POST, pero se que hay algo mal y no logro verlo... Espero me ayuden... Gracias