PHP e Mysql: Adicionar ao Banco de Dados

Fevereiro 9, 2008

< ?php include("../src/conectar.php"); ?>
< ?
$data =  date("Y-m-d H:i:s");
$titulo = htmlentities($_POST['titulo']);
$texto = htmlentities($_POST['texto']);
$tabela = "conteudo";
$campos = "datahora, titulo, texto";
$dados = "'$data', '$titulo', '$texto'";
$query = "INSERT INTO ".$tabela." (".$campos.") VALUES (".$dados.")";
$sql = mysql_query($query) or print(mysql_error());

header("Location: pagina.php"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>

Entry Filed under: MySql, PHP, Programação Web. Tags: , , , , , , , , , , , .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Tópicos recentes

Comandos e Funções

mais acessados

Comentários

andre luiz em Validar formulário em Jav…
Rafaela Poiani em Validar formulário em Jav…
Vanessa em Validar formulário em Jav…