Código PHP:
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "editor")) {
$insertSQL = sprintf("INSERT INTO post (titulo_post, post, data_time, username, juego, categorias) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['texto'], "text"),
GetSQLValueString($_POST['data_time'], "date"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['selec'], "text"),
GetSQLValueString($_POST['categorias'], "text"));
mysql_select_db($database_coneccion, $coneccion);
$Result1 = mysql_query($insertSQL, $coneccion) or die(error());
$insertGoTo = "posteado.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header("Location: posteado.php");
//header(sprintf("Location: %s", $insertGoTo));
}
$maxRows_Recordset1 = 100;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_coneccion, $coneccion);
$query_Recordset1 = "SELECT * FROM post ORDER BY id_post DESC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $coneccion) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
mysql_select_db($database_coneccion, $coneccion);
$query_nombre_del_juego = "SELECT * FROM `admin`";
$nombre_del_juego = mysql_query($query_nombre_del_juego, $coneccion) or die(mysql_error());
$row_nombre_del_juego = mysql_fetch_assoc($nombre_del_juego);
$totalRows_nombre_del_juego = mysql_num_rows($nombre_del_juego);
?>
<html>´
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<?php java();?>
</head><body onLoad="elEditor = ini_editor(document.getElementsByTagName('textarea')[0])">
<?php require ("clases.php");
$clase_clases = new Clases();
$clase_clases->estilos();
$clase_clases->LOGO_Cabecara();
$clase_clases->Botonera();
?>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#406A99">
<tr>
<td background="imagenes/boton_02a.png"> </td>
</tr>
<tr>
<td>
<form action="<?php echo $editFormAction; ?>" method="POST" name="editor" onSubmit="preview(this)">
<div align="center">
<h3>Publica tu post</h3>
<strong>Titulo del post</strong>
<input name="titulo" type="text" id="titulo" size="50" value="<?php echo $_POST['titulo']?>">
<input name="username" type="hidden" value="<?php echo $_SESSION['s_username'];?>">
<input name="data_time" type="hidden" value="<?php $data_time = date("Y-m-d H:i:s"); echo $data_time; ?>">
<br><br>
<strong>Elige el juego</strong>
<select name="selec" size="1" >
<option value=""selected="selected">Seleccionar Juego</option>
<option></option>
<option value="Software">Software</option>
</select> <br>
<br>
<input name="button" type="button" id="tabulador" onClick="centrar()" onMouseOver="cambiaColor(this.id)" onMouseOut="recuperaColor(this.id)" value=" Centrar">
<input name="button" type="button" id="insertor" style="background-color: rgb(238, 238, 238); color: rgb(0, 0, 0);" onClick="imagen()" onMouseOver="cambiaColor(this.id)" onMouseOut="recuperaColor(this.id)" value="Insertar imagen" vamospor="37" cambiandocolor="0">
<input name="button" type="button" id="resultados" style="background-color: rgb(238, 238, 238); color: rgb(0, 0, 0);" onClick="grande()" onMouseOver="cambiaColor(this.id)" onMouseOut="recuperaColor(this.id)" value="Agrandar texto" vamospor="37" cambiandocolor="0">
<input name="button" type="button" id="comillador" style="background-color: rgb(238, 238, 238); color: rgb(0, 0, 0);" onClick="negrita()" onMouseOver="cambiaColor(this.id)" onMouseOut="recuperaColor(this.id)" value="negrita" vamospor="37" cambiandocolor="0">
<input name="button" type="button" id="url" style="background-color: rgb(238, 238, 238); color: rgb(0, 0, 0);" onClick="uri()" onMouseOver="cambiaColor(this.id)" onMouseOut="recuperaColor(this.id)" value=" URL " vamospor="37" cambiandocolor="0">
<input name="button" type="button" id="Video" style="background-color: rgb(238, 238, 238); color: rgb(0, 0, 0);" onClick="video()" onMouseOver="cambiaColor(this.id)" onMouseOut="recuperaColor(this.id)" value=" Video YouTube " vamospor="37" cambiandocolor="0">
<br>
<script type="text/javascript">
for (i = 0; i < emotis.length; i ++)
document.writeln("<img src='index_files/" + fichs[i] + "' onclick='ponerEmoticon(\"" + emotis[i] + "\")' style='cursor: pointer' />");
</script>
<br>
<textarea name="texto" id="texto" cols="80" rows="20" onFocus="elEditor = ini_editor(this)"><?php echo $_POST['texto']?></textarea>
<br>
<br>
<strong>Categorias</strong><br>
<select name="categorias">
<option value=""selected="selected">Seleccionar Categoria</option>
<option value="Hamachi">Hamachi</option>
<option value="Links Descargas">Links Descargas</option>
<option value="Tutoriales">Tutoriales</option>
<option value="Trucos">Trucos</option>
<option value="Partidas Grabadas">Partidas Grabadas</option>
</select>
<br>
<br>
<input type="submit" name="Submit" value="Publicar post">
<br>
</div>
<input type="hidden" name="MM_insert" value="editor">
</form> </td>
</tr>
<tr>
<td background="imagenes/boton_02a.png"> </td>
</tr>
</table>
</body></html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($nombre_del_juego);
} else {
require ("clases.php");
$clase_clases = new Clases();
$clase_clases->Mostrar_1();
?>
<br>
<br>
<br>
<br>
<center>Para postear tienes que iniciar sesion...!!!</center><br>
<br>
<br>
<br>
<?php
$clase_clases->Mostrar_2();
}
?>