Foros del Web » Programando para Internet » PHP »

Una ayudita porfa!! :)

Estas en el tema de Una ayudita porfa!! :) en el foro de PHP en Foros del Web. Hola que tal, bueno estoy realizando una validacion con sessio_start(), mi formulario funciona muy bien!. El problema es: cuando quiero enviar los datos a la ...
  #1 (permalink)  
Antiguo 29/05/2009, 15:04
Avatar de Jesua  
Fecha de Ingreso: septiembre-2008
Ubicación: Guatemala, Guatemala
Mensajes: 29
Antigüedad: 15 años, 7 meses
Puntos: 0
Una ayudita porfa!! :)

Hola que tal, bueno estoy realizando una validacion con sessio_start(), mi formulario funciona muy bien!. El problema es: cuando quiero enviar los datos a la DB_ no me da ningun problema, pero cuando yo reviso la DB_ no aparece ningun dato. que puedo hacer al respecto! aca dejo el codigo! Y muchas gracias.


=form.php

<?
// inicia php session_satar();
session_start();

// errores de la session.
$error = $_SESSION[ 'error' ];
// Confirmacion de formulario
$msg = $_SESSION[ 'msg' ];

?>

<?
if ( strlen( trim( $error ) ) > 0 ) {
?>
<br><br>Favor arreglar los sigueintes errores:<br>
<?= $error ?>
<br><br>

<?
}// if

if ( strlen( trim( $msg ) ) > 0 ) {
?>
<br><br><?= $msg ?><br><br>
<?
}// if
?>

<form name="form" id="form" action="process.php">

<ul>nombre:<input type="text" name="nombre" value="<?= $_SESSION['nombre'] ?>"></ul>
<ul>e-mail:<input type="text" name="mail" value="<?= $_SESSION['mail'] ?>"></ul>
<ul>Telefono:<input type="text" name="tel" value="<?= $_SESSION['tel']?>"></ul>
<ul>Comentario:<textarea rows="5" cols="25" name="cmsg" value="<?= $_SESSION['cmsg']?>"></textarea></ul>
<ul><input type="submit" value="Enviar"><input type="reset" value="Limpiar"></ul>

</form>


<?
// limpiar info de mensaje
unset ( $_SESSION['msg'] );
//limpiar mensaje de error
unset ( $_SESSION['error']);

?>


=process.php


<?
// start PHP session
session_start();

// clear confirmation message
unset( $_SESSION[ 'msg' ] );
// clear error message
unset( $_SESSION[ 'error' ] );

$error = "";
//nombre
$nombre = $_REQUEST[ 'nombre' ];
if ( strlen( trim( $nombre ) ) < 1 ) {
$error .= "<li>Se requiere un nombre</li>";
}// if
$_SESSION[ 'nombre' ] = trim( $nombre );

//mail
$mail = $_REQUEST[ 'mail' ];
if ( strlen( trim( $mail ) ) < 1 ) {
$error .= "<li>Se requiere un e-mail</li>";
}// if
$_SESSION[ 'mail' ] = trim( $mail );

//tel
$tel = $_REQUEST[ 'tel' ];
if ( strlen( trim( is_numeric ($tel) ) ) < 1 ) {
$error .= "<li>Se requiere un Telefono o Valor numerico</li>";
}// if
$_SESSION[ 'tel' ] = trim( $tel );

//msg
$cmsg = $_REQUEST['cmsg'];
if (strlen(trim( $cmsg )) < 1){
$error .="<li>Se requiere un mensaje</li>";
}//if
$_SESSION['cmsg'] = trim ( strip_tags( $cmsg ));

//prosesando formulario y buscando errores si hay errores haga esto! sino ->
if ( strlen( trim( $error ) ) > 0 ) {
// set errorMsg in session
$_SESSION[ 'error' ] = $error;
} else {
// set confirmation message
$_SESSION[ 'msg' ] = "Gracias,<br> " ." $nombre<br> ". "$mail<br> " . "$tel<br>" ." $cmsg<br> ". ", Tu informacion fue enviada correctamente";

// clear form values and error message
unset( $_SESSION[ 'nombre' ] );
unset( $_SESSION[ 'mail' ] );
unset( $_SESSION[ 'tel' ] );
unset($_SESSION[ 'cmsg' ]);
}// if-else

// redireccionar y revisar si los datos estan llenos!...



//funcion para mysql_conection;
if($_SESSION['nombre'] . $_SESSION['tel'] . $_SESSION['mail'] . $_SESSION['cmsg'] ==true){
//coneccion a la BD_ mysql.
function crearConeccion (){
$USUARIO = "root";
$HOSTNAME = "localhost";
$PWD = "3333";
$DB_NAME = "db_once";

$coneccion = mysql_connect ( $USUARIO, $HOSTNAME, $PWD);
if( $coneccion ){
mysql_select_db ( $coneccion, $DB_NAME) or die ('No se puede conectar a la DB_');
return $coneccion;
}else {
echo "No se puede seleccionar<BR>" . $DB_NAME;
}//if-else
}//function crearConeccion
//solicitando datos para la DB_

if( $_SESSION['nombre'] . $_SESSION['mail'] . $_SESSION['tel'] . $_SESSION['cmsg'] == true){
$coneccion = crearConeccion();
//introducir en la DB_
if ($coneccion){
$sql = "insert into db_once (nombre, mail, tel, cmsg) values ('". $_SESSION['nombre'] ."','". $_SESSION['mail'] ."','". $_SESSION['tel'] ."','". $_SESSION['cmsg'] ."')";
$suceso = mysql_query ( $coneccion, $sql);
if (!$suceso){echo "Error con sql" . $sql;}
}//if coneccion
}//if

}//if msg = true all function


header( "Location: form.php" );




?>
  #2 (permalink)  
Antiguo 29/05/2009, 15:25
Avatar de By_George  
Fecha de Ingreso: abril-2009
Ubicación: localhost
Mensajes: 629
Antigüedad: 15 años
Puntos: 19
Respuesta: Una ayudita porfa!! :)

agregale un or die a tu consulta a ver que error te manda

$suceso = mysql_query ( $coneccion, $sql) or die("el error es: ".mysql_error());
__________________
La estadística es una ciencia que demuestra que si mi vecino tiene dos coches y yo ninguno, los dos tenemos uno.
  #3 (permalink)  
Antiguo 29/05/2009, 15:34
 
Fecha de Ingreso: febrero-2009
Ubicación: cancun!
Mensajes: 898
Antigüedad: 15 años, 2 meses
Puntos: 15
Respuesta: Una ayudita porfa!! :)

intenta hacer la consulta directamente en mysql es decir si usas phmyadmin abrelo y haz una insercion para ver que errores te arroja sospecho del tamaño o permisos de BD saludines
y HOLA BY_... jaja
__________________
WHERE IS MY BLUE SUNNY SKY??
pd: todos los karmas son bienvenidos :D
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:00.