),Estoy terminando un formualrio de registro en mi proyecto y quiero incorporar un captcha que enviará un correo electrónico al usuario para completar el registro y asi evitar en lo posible los registros indeseados.
El captcha que estoy usando es el de securimage que parece ser bastante bueno, he adaptado el formulario inicial a mis requisitos para incluirlo en el mio (eliminando campos que ya tengo) pero tengo un problema con las sesiones ¿que raro no
?Os adjunto los codigos del formulario:
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd "> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es"> <meta http-equiv="Content-Type"content=" text/html;charset=utf-8"> <!--onsubmit="this.submit(); this.reset(); return false"> --> <form method="post" action="../DBQuery/RegistroPersona.php" enctype="multipart/form-data"> <form> <!--Tabla Personas de la Base de datos--> <fieldset> <legend>Datos Personales</legend> <label for="nombre">Nombre:</label><input type="text" name="nombre" id="nombre"size="40"/><br/><br/> <label for="apellido1">Apellido 1º:</label><input type="text" name="apellido1" id="apellido1"/> <label for="apellido2">Apellido 2º:</label><input type="text" name="apellido2" id="apellido2"/><br> <label for="imagen">Foto:<input type="file" name="imagen" size="40"><br> </fieldset> <fieldset> <legend>Contraseña</legend> <p>Indique aquí su usuario y su contraseña por favor. Guárdelos en un lugar que recuerde por si los olvida o los pierde</p> <label for="usuario">Usuario:</label><input type="text" name="usuario" id="usuario"/><br/> <label for="clave">Contraseña:</label><input type="password" name="clave" id="clave"/><br/> <label for="clave2">Por favor repita la contraseña:</label><input type="password" name="clave2" id="clave2"/><br/> <label for="preguntaClave">Pregunta secreta:</label><input type="text" name="preguntaClave" id="preguntaClave" size="80"/><br/><br/> <label for="respuestaClave">Respuesta secreta:</label><input type="text" name="respuestaClave" id="respuestaClave" size="80"/><br/><br/> <label for="mailPersona">Correo electrónico:</label><input type="text" name="mailPersona" id="mailPersona" size="80"/><br/><br/> </html> <?php // Captcha include_once('securimage/nmbscaptcha.php'); /*Iniciamos sesion. Como no hay ninguna sesion iniciada, se crea, con un session_i alfanumérico aleatorio */ session_start (); /*Se indican las variables de inicio de sesion*/ session_register ($usuario,$clave); ?> <html> <!-- Se crea un cammpo oculto para enviar la constante de sesion id --> <input type="hidden" name="<?php echo (session_name());?>" value=" </html> <?php echo (session_id());?>"> ?> <html> <!--Envio los datos--> <input type="submit"value="Enviar" /> <input type="reset"value="Borrar" /> </fieldset> <!--Reseteo el Formulario--> <body onload ="document.myform.reset()"> </form> </html>
Código PHP:
<?php
/**
* Project: Securimage: A PHP class for creating and managing form CAPTCHA images<br />
* File:
securimage.php<br />
* URL: www.phpcaptcha.org
*/
session_start();
// Start the session where the code will be stored.
?>
<html>
<body>
<?php
if (empty($_POST)) { ?>
<div style="width: 430px; float: left; height: 90px">
<img id="siimage" align="left" style="padding-right: 5px; border: 0" src="securimage_show.php?sid=
<?php
echo md5(time()) ?>" />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="19" height="19"
id="SecurImage_as3" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="securimage_play.swf?
audio=securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5" />
<param
name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="securimage_play.swf?audio=securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5"
quality="high" bgcolor="#ffffff" width="19" height="19" name="SecurImage_as3" align="middle"
allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
<br />
<!-- pass a session id to the query string of the script to prevent ie caching -->
<a tabindex="-1" style="border-style: none" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src
= 'securimage_show.php?sid=' + Math.random(); return false">
<img src="images/refresh.gif" alt="Reload Image" border="0" onclick="this.blur()" align="bottom" /></a>
</div>
<div
style="clear: both">
</div>Código:<br />
<!-- NOTE: the "name" attribute is "code" so that $img->check($_POST['code']) will check the submitted form field -->
<form method="POST">
<input type="text" name="code" size="12" /><br /><br />
</form>
<?php
}
else { //form is posted
include("securimage.php");
$img = new Securimage();
$valid = $img->check($_POST['code']);
if($valid == true) {
echo "<center>Thanks, you entered the correct code.<br />Click <a href=\"{$_SERVER
['PHP_SELF']}\">here</a> to go back.</center>";
} else {
echo "<center>Sorry, the code you entered was invalid. <a
href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>";
}
}
?>
</body>
</html> Cita:
¿Alguien puede indicarme que es lo que estoy haciendo mal y darme una solución?Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\rgs_gral_cons.php:4) in C:\xampp\htdocs\phpBits\BodyForm_Txt_RGTCon.php on line 43
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\rgs_gral_cons.php:4) in C:\xampp\htdocs\phpBits\BodyForm_Txt_RGTCon.php on line 43
?>
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\rgs_gral_cons.php:4) in C:\xampp\htdocs\phpBits\BodyForm_Txt_RGTCon.php on line 43
?>
NO entiendo lo que me indica el error. De nuevo mi ignorancia ancestral.



Muchas gracias por adelantado y os deseo lo mejor para el próximo año (y el resto de viestra vida
)J.


) respuesta. Cuando dices al principio ¿a que te refieres con exactitud? me explico, como voy haciendo includes de unos escripts a otros no se si debo declarar las sesiones al inicio del script "principal" que va llamando los includes o, por el contrario, debo declarar la sesion en todos los scripts con independencia de si luego son llamados o no por otro mediante include.


