Ver Mensaje Individual
  #7 (permalink)  
Antiguo 01/12/2009, 09:31
etisdemian
 
Fecha de Ingreso: octubre-2009
Mensajes: 357
Antigüedad: 14 años, 6 meses
Puntos: 1
Respuesta: la pagina no advierte los errores

ya aki esta todito
2comento que al inicio aparece require....y una coneccion
pero arrojaba un problema con la conneccion odbc@host ,pass invalido
asi es que puse manual abajito una coneccion mas arcaica
veamos.....



<?php require_once('../Connections/tutorial.php'); ?>

<?php
$con = mysql_connect("localhost","xxxxx","xxxxxx");
// si el formulario ha sido enviado, convertir subarrays $_POST a strings
if (array_key_exists('enviar', $_POST)) {
if (isset($_POST['areas'])) {
$_POST['areas'] = implode(',', $_POST['areas']);
}

else {
$_POST['areas'] = '';
}
if (isset($_POST['preferencias'])) {
$_POST['preferencias'] = implode(',', $_POST['preferencias']);
}
else {
$_POST['preferencias'] = '';
}
}
?>

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO comentarios (nombre, email, comentario, areas, frecuencia, preferencias, suscribir) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['comentario'], "text"),
GetSQLValueString($_POST['areas'], "text"),
GetSQLValueString($_POST['frecuencia'], "text"),
GetSQLValueString($_POST['preferencias'], "text"),
GetSQLValueString($_POST['suscribir'], "text"));

mysql_select_db($database_tutorial, $tutorial);
$Result1 = mysql_query($insertSQL, $tutorial) or die(mysql_error());

if ($_POST["MM_insert"]) {
//Redireccionar a una página con URL completa
header ('Location: http://www.pagina.com');
exit;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contacto</title>
<link href="css/contacto.css" rel="stylesheet" type="text/css" />
</head>

<body>
<h1>Env&iacute;a Un Comentario</h1>
<p>Agradecemos los comentarios que nos pueda enviar. Por favor usa el siguiente formulario para hacernos saber lo que piensas de nuestro sitio.</p>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
<p>&nbsp;</p>
<fieldset>
<legend>Tus datos</legend>
<p>

<label for="nombre">Nombre: <?php if (isset($perdido) && in_array('nombre', $perdido)) { ?>
<span class="advertencia">Por favor, escriba su nombre</span><?php } ?>
</label>

<input name="nombre" type="text" class="textInput" id="nombre"
<?php if (isset($perdido)) {
echo 'value=" '.htmlentities($_POST['nombre']).' " ';
}
?>
/>
</p>
<p>
<label for="email">Email:</label>
<input name="email" type="text" class="textInput" id="email"
<?php if (isset($perdido)) {
echo 'value=" '.htmlentities($_POST['email']).' " ';
}
?>
/>
</p>
</fieldset>
<fieldset>
<legend>Tus Opiniones</legend>
<p>
<label for="comentario">Comentario:<?php if (isset($perdido) && in_array('comentario', $perdido)) { ?>
<span class="advertencia">Por favor, escriba su comentario</span><?php } ?>
</label>
<textarea name="comentario" cols="45" rows="4" id="comentario">
<?php if (isset($perdido)) {
echo htmlentities($_POST['comentario']);
}
?>
</textarea>
</p>
<p><strong>¿Sobre qué temas deseas información?</strong></p>
<div class="cheq">
<p>
<input name="areas[]" type="checkbox" id="arte" value="arte"
<?php
$correcto = isset($_POST['areas']) ? true : false;
if ($correcto && isset($perdido) && in_array('arte', $_POST['areas'])) {
echo 'comprobado="comprobado"';
} ?>

/>

<label for="arte">Arte</label>
</p>
<p>
<input name="areas[]" type="checkbox" id="literatura" value="literatura"
<?php
if ($correcto && isset($perdido) && in_array('literatura', $_POST['areas'])) {
echo 'comprobado="comprobado"';
} ?>

/>
<label for="literatura">Literatura</label>
</p>
<p>
<input name="areas[]" type="checkbox" id="medicina" value="medicina"
<?php
if ($correcto && isset($perdido) && in_array('medicina', $_POST['areas'])) {
echo 'comprobado="comprobado"';
} ?>

/>
<label for="medicina">Medicina</label>
</p>
</div>
<div class="cheq">
<p>
<input name="areas[]" type="checkbox" id="pedagogia" value="pedagogia"
<?php
if ($correcto && isset($perdido) && in_array('pedagogia', $_POST['areas'])) {
echo 'comprobado="comprobado"';
} ?>

/>
<label for="pedagogia">Pedagogía</label>
</p>
<p>
<input name="areas[]" type="checkbox" id="pedagogia" value="otras"
<?php
if ($correcto && isset($perdido) && in_array('otras', $_POST['areas'])) {
echo 'comprobado="comprobado"';
} ?>
/>
<label for="otras">Otras</label>
</p>
</div>
<p class="clearIt">
<label for="frecuencia">¿Cuántas veces visitas este sitio?
<?php
if (isset($perdido) && in_array('frecuencia', $perdido)) { ?>
<span class="advertencia">Por favor, selecciona un valor</span><?php } ?>

</label>
<select name="frecuencia" id="frecuencia">
<option value="0"
<?php
if (!$_POST || $_POST['frecuencia'] == '0') {
echo 'selected="selected"';
} ?>
selected="selected">-- Selecciona uno --</option>
<option value="nunca"
<?php
if (isset($perdido) && $_POST['frecuencia'] == 'nunca') {
echo 'selected="selected"';
} ?>
>Nunca Antes</option>
<option value="varias"
<?php
if (isset($perdido) && $_POST['frecuencia'] == 'varias') {
echo 'selected="selected"';
} ?>
>Varias Veces</option>
<option value="bastantes"
<?php
if (isset($perdido) && $_POST['frecuencia'] == 'bastantes') {
echo 'selected="selected"';
} ?>

>Bastantes Veces</option>
<option value="diario"
<?php
if (isset($perdido) && $_POST['frecuencia'] == 'diario') {
echo 'selected="selected"';
} ?>

>Todos los d&iacute;as</option>
</select>
</p>
<p>
<label for="preferencias">¿Qué temas te interesan más?</label>
<select name="preferencias[]" size="6" multiple="multiple" id="preferencias">
<option value="dise"
<?php
$OK = isset($_POST['preferencias']) ? true : false;
if ($OK && isset($perdido) && in_array('dise', $_POST['preferencias'])) {
echo 'selected="selected"';
} ?>

>Dise&ntilde;o</option>
<option value="program"
<?php
$OK = isset($_POST['preferencias']) ? true : false;
if ($OK && isset($perdido) && in_array('program', $_POST['preferencias'])) {
echo 'selected="selected"';
} ?>

>Programaci&oacute;n</option>
<option value="web"
<?php
$OK = isset($_POST['preferencias']) ? true : false;
if ($OK && isset($perdido) && in_array('web', $_POST['preferencias'])) {
echo 'selected="selected"';
} ?>

>Web</option>
<option value="juegos"
<?php
$OK = isset($_POST['preferencias']) ? true : false;
if ($OK && isset($perdido) && in_array('juegos', $_POST['preferencias'])) {
echo 'selected="selected"';
} ?>

>Juegos</option>
<option value="educa"
<?php
$OK = isset($_POST['preferencias']) ? true : false;
if ($OK && isset($perdido) && in_array('educa', $_POST['preferencias'])) {
echo 'selected="selected"';
} ?>

>Educativos</option>
<option value="multimedia"
<?php
$OK = isset($_POST['preferencias']) ? true : false;
if ($OK && isset($perdido) && in_array('multimedia', $_POST['preferencias'])) {
echo 'selected="selected"';
} ?>

>Multimedia</option>
</select>
</p>
<p><strong>¿Quieres recibir noticias del sitio?</strong></p>
<div class="cheq">
<p>
<input type="radio" name="suscribir" id="suscribeSi" value="S"
<?php
if (isset($perdido) && $_POST['subscribir'] == 'S') {
echo 'marcado="marcado"';
} ?>

/>
<label for="suscribeSi">S&iacute;</label>
<input type="radio" name="suscribir" id="suscribeNo" value="n"
<?php
if (isset($missing) && $_POST['subscribe'] == 'n') {
echo 'marcado="marcado"';
} ?>
/>
<label for="suscribeNo">No</label>
</p>
</div>
<p class="clearIt">
</fieldset>
<label for="enviar"></label>
<input name="enviar" type="submit" class="clearIt" id="enviar" value="Enviar Comentario" />
<input type="hidden" name="MM_insert" value="form1" />
</p>

</form>

</body>
</html>