Ver Mensaje Individual
  #6 (permalink)  
Antiguo 15/07/2011, 09:30
juanjpina
 
Fecha de Ingreso: julio-2011
Mensajes: 5
Antigüedad: 12 años, 9 meses
Puntos: 0
Respuesta: wampserver no ejecuta php

el script



<?php
phpinfo();


//si las comillas magicas estan activadas escapar barras
if (get_magic_quotes_gpc()){
foreach ($_POST as $key => $value){
$_POST[$key] = stripslashes($value);
}
}
//extraer envio de formulario
$title = (isset($_POST["title"]))
?$_POST["title"]:"";
$postdate = (isset($_POST["postdate"]))
?$_POST["postdate"]:"";
$summary = (isset($_POST["summary"]))
?$_POST["summary"]:"";
$post = (isset($_POST["post"]))
?$_POST["post"]:"";
$submitAdd = (isset($_POST["submitAdd"]))
?$_POST["submitAdd"]:"";


//preparar datos para la base de datos
$db_title = addslashes ($title);
$db_postdate = addslashes ($postdate);
$db_summary = addslashes ($summary);
$db_post = addslashes ($post);

//si envia el formulario insertar
//mensaje en la base de datos
if ($submitAdd){
$sql = "INSERT INTO posts (title,postdate,summary,post)
VALUES ('$db_title', '$db_postdate', '$db_summary', '$db_post')";
$result = mysql_query($sql);
if (!$result) {
$message = "Failed to insert post.
MySQL said " . mysql_error();
} else {
$message = "Successfully inserted post '$title'.";
}
}

//obtener post_id de la cadena de consulta
$post_id = (isset($_REQUEST[post_id]))
?$_REQUEST["post_id"]:"";

//si post_id es un numero, obtener mensaje de la base de datos
if (preg_match("/^[0-9]+$/", $post_id)){
$editmode = true;
$sql = "SELECT title, postdate, summary, post FROM posts WHERE post_id=$post_id";
$result = mysql_query($sql);
$mypost = mysql_fetch_array($result);
if ($mypost) {
$title = $mypost["title"];
$postdate = $mypost["postdate"];
$summary = $mypost ["summary"];
$post = $mypost ["post"];
}else {
$message = "No post matching that post_id.";
}

}else {
$editmode = false;
}



?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Add a post - blog CMS</title>
<meta name="generator" content="Studio 3 http://aptana.com/">
<meta name="author" content="Juanjo">
<!-- Date: 2011-07-13 -->
</head>
<body>
<h1>Add a post</h1>

<?php
if (isset($message)) {
echo "<p class='message'>$message</p>";
}
?>


<form method="post" action="<?php echo $_SERVER["PHP_SELF"] ?>">
<p>Title:<input type="text" name="title" size="40" value="<?php if (isset ($title)) {echo $title;}?>"/></p>
<p>Date/Time: <input type="text" name="postdate" size="40"/> yyyy-mm-dd hh: ss:</p>
<p>Summary: <br/>
<textarea name="summary" rows="5" cols="60"><?php if (isset($summary)) {echo $summary;}?></textarea>
</p>
<textarea name="post" rows="20" cols="60"><?php if (isset ($post)){echo $post;} ?></textarea>
<p><input type="Submit" name="submitAdd" value="Add post"/></p>

</form>


</body>
</html>