Hola amgios tengo un problema al agregar un post y una imagen una imagen en php
en agregar.php
en agregar.php
<form onsubmit="return false" name="formEdit" id="formEdita">
<input type="text" name="titulo" id="titulo" class="mi_titulo" placeholder="Titulo..." maxlength="68"><br>
<div class="global">
<div class="size21">Adjuntivos (max 3mb)</div><input name="userfile" style="color: #fff;" type="file" class="upload_file-input"></div><br>
<div id="boton_publi"><span class="error_red_com" style="display:none"></span>
<div id="precarga_envio_p" style="display:none"></div><input type="button" class="btn_publicar" name="botoncom" id="botoncom" value="Publicar" onclick="ckeditor();enviartema(titulo.value,mensajes.value,categoria.value);"></div>
<textarea name="mensajes" id="mensajes" class="textarea_post" placeholder="Nuevo tema..." ></textarea>
<input type="hidden" name="categoria" id="categoria" value="<? echo $row_sacar_tags['cat']?>">
</form></div>
<script>
CKEDITOR.replace( 'mensajes',
{
height: '350px',
});
</script>
</div>add_post.php<?php require('../Connections/conexion.php');
$titulo = $_POST['titulo']; //TITLE
$user =$_COOKIE['idcookie'];
$contenido = $_POST['mensajes'];
$cat = $_POST['categoria'];
$ip = $_SERVER['REMOTE_ADDR'];
$status = 1;
$seopost = $_POST['titulo'];// seamos el contendio del post que
//Subir imagen
$uploaddir = $urlWeb.'img/upload/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
$insertSQL = sprintf("INSERT INTO r_posts (titulo,contenido,seo,cat,autor,ip,estado,imagen) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
GetSQLValueString($titulo, "text"),
GetSQLValueString($contenido, "text"),
GetSQLValueString(urls_amigables($seopost), "text"),
GetSQLValueString($cat, "int"),
GetSQLValueString($user, "int"),
GetSQLValueString($ip, "text"),
GetSQLValueString($status, "int"),
GetSQLValueString($uploadfile, "text"));
mysql_select_db($database_conexion, $conexion);
$Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
mysql_select_db($database_conexion, $conexion);
$query_open_post = "SELECT * FROM r_posts WHERE cat=$cat ORDER BY id DESC LIMIT 1 ";
$open_post = mysql_query($query_open_post, $conexion) or die(mysql_error());
$row_open_post = mysql_fetch_assoc($open_post);
$totalRows_open_post = mysql_num_rows($open_post);
echo $row_open_post['id'].'/'.$row_open_post['seo'];
mysql_free_result($open_post);
?>
espero que me puedan ayudar0
Puntos
Puntos
1547
Visitas
Visitas
3
Resp
Resp
Por fc2014 hace 11 años
Master
Respuesta #1
el error es aca
mira
mira
<br> <b>notice</b>: undefined index: userfile in <b> d:xampp/htdocs/web/inc/add_post.php</b> on line 12</b><br> colummn "contenido" connot be null
0
Puntos
Puntos
Por fc2014 hace 11 años
Master
Respuesta #2
Hola :P
¿Cuál es el problema en detalle? Si puedes coloca el código ajax de enviartema() a ver si la cosa va por ahí..
¿Cuál es el problema en detalle? Si puedes coloca el código ajax de enviartema() a ver si la cosa va por ahí..
0
Puntos
Puntos
Por jose hace 11 años
Master
Respuesta #3
Hola jose ahi va el codigo de ejectos.js
function enviartema(titulo,mensajes,categoria){
conteotitulo = titulo.split(" ").join("");
pasadauno = mensajes.split(" ").join("");
pasadados = pasadauno.split(" ").join("");
pasadatres = pasadados.split("<br/>").join("");
/*pasadados = conteomensaje.replace(/(<([^>]+)>)/ig,"");*/
if (titulo==''){
$('.error_red_com').html('Se necesita un t\u00edtulo');
$('.error_red_com').hide().fadeIn();
setTimeout(function(){$('.error_red_com').fadeOut();},2000);
}
else if (conteotitulo.length<20){
$('.error_red_com').html('El t\u00edtulo es muy corto');
$('.error_red_com').hide().fadeIn();
setTimeout(function(){$('.error_red_com').fadeOut();},2000);
}
else if (conteotitulo.length>68){
$('.error_red_com').html('El t\u00edtulo es muy largo');
$('.error_red_com').hide().fadeIn();
setTimeout(function(){$('.error_red_com').fadeOut();},2000);
}
else if (mensajes==''){
$('.error_red_com').html('Se necesita un tema');
$('.error_red_com').hide().fadeIn();
setTimeout(function(){$('.error_red_com').fadeOut();},2000);
}
else if (pasadatres.length<89){
$('.error_red_com').html('El tema es muy corto');
$('.error_red_com').hide().fadeIn();
setTimeout(function(){$('.error_red_com').fadeOut();},2000);
}
else {
$('.error_red_com').css("display","none");
$('#precarga_envio_p').css("display","block");
document.getElementById('botoncom').disabled=true;
setTimeout(function(){
var este=$('#formEdita');
$.ajax({
type: 'POST',
url: urlWeb + 'inc/add_post.php',
data: 'titulo=' + titulo + '&mensajes=' + mensajes + '&categoria=' + categoria,
success: function(htmlres) {
alert(htmlres);
/* location.href= urlWeb + 'post/' + htmlres;*/
/* $('#titulo').val('');
$('#mensajes').val('');*/
$('#precarga_envio_p').css("display","none");
}
});
},2000);
}
}
0
Puntos
Puntos
Por fc2014 hace 11 años
Master