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: MySql, mysql INSERT, mysql INTO, mysql VALUES, PHP, php date(), php header(), php htmlentities(), php include(), php mysql_error(), php mysql_query(), php print().
Trackback this post | Subscribe to the comments via RSS Feed