Ver Mensaje Individual
  #11 (permalink)  
Antiguo 24/06/2012, 19:49
Avatar de gildus
gildus
 
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 21 años, 3 meses
Puntos: 105
Respuesta: Problema con formulario con captcha "Could not open socket"

Holas,

Evita a que te den codigo o todo el codigo que deseas, es muy mala costumbre a mi opinon, pero vale, aqui te lo paso:

Código PHP:
Ver original
  1. <?php
  2. header("Content-Type: text/xml;charset=UTF-8");
  3.  
  4. include('header.php');
  5.  
  6.  
  7. $errors = "";
  8.  
  9. $username = $_POST['username'];
  10. $password = $_POST['password'];
  11. $password2 = $_POST['password2'];
  12. $email = $_POST['email'];
  13. $ip = $_SERVER['REMOTE_ADDR'];
  14.  
  15. if (empty($username) || empty($password) || empty($password2) || empty($email)){
  16.     $errors .= 'Please enter something in all of the fields.<br/>';
  17. }
  18. if (strlen($username) < 3 || strlen($username) > 20){
  19.     $errors .= 'Please keep your username between 3 and 20 letters.<br/>';
  20. }
  21. if ($password != $password2){
  22.     $errors .= 'The passwords you entered do not match.<br/>';
  23. }
  24. if (!preg_match("/^[a-z][a-z0-9_.-]+@[a-z0-9][a-z0-9-]+\.[a-z]+(\.[a-z]+)*$/i", $email)){
  25.     $errors .= 'The e-mail address you entered is not valid.<br/>';
  26. }
  27. if (strlen($email) > 40){
  28.     $errors .= 'Please keep your e-mail address lower than 40 letters.<br/>';
  29. }
  30.  
  31. $check_username = mysql_query("SELECT `id` FROM `users` WHERE `username`='$username'");
  32. $check_email = mysql_query("SELECT `id` FROM `users` WHERE `email`='$email'");
  33.  
  34. if (mysql_num_rows($check_username) != 0) {
  35.     $errors .= 'That username is already taken by another user.<br/>';
  36. }
  37. if (mysql_num_rows($check_email) != 0) {
  38.     $errors .= 'We only allow one account per user.<br />';
  39. } else {
  40.     if($errors == "") {
  41.         $password = md5(md5(sha1($password)));
  42.         $time = time();
  43.  
  44.         mysql_query("INSERT INTO `users` (`username`,`password`,`email`,`ip`,`reg_date`) VALUES ('$username', '$password', '$email', '$ip', '" . date('Y-m-d H:i:s',time()) . "')");
  45.     }
  46. }
  47.  
  48. if($errors != "") {
  49.     $maincontent = $errors;
  50. } else {
  51.     $maincontent = "<strong>You have registered successfully!</strong> You may now log in.";
  52. }
  53.  
  54. $publickey = "6LeC9dISAAAAALgCYFVWW8ZLPIw6WGN34BGf5COQ";
  55.  
  56. ?>
  57. <code><?php
  58. /* Donne
  59.     Array
  60.     (
  61.         [username] => khalid
  62.         [password] => khalidpwd
  63.         [password2] => khalidpwd
  64.         [email] => [email protected]
  65.         [recaptcha_challenge_field] => 02J5iH75gdOFfyKNrvFr-Hz9MPxo4nrpoRWu_x-wP6v0oPK8rLZzMvd5cPtKpMcu8
  66.     jZcMJxryo3TNW9bTtHghAu5PAwYtbJQQovzPM8t3GMOmih2Qan3iD8Mdou_pwDgj2H8B9sl8FI-MFJUPEHZeG3RvYodxGw1uPxh3
  67.     yls9H4qOrYgg8lnuOB5mm4mO9L03vrB3FQLMmlxorK29RAm2aIWQ7rXLZMeZ0LFR-_QngSNQwRuj3m0NCUpGUXOXjHiDoUsfzQ0K
  68.     6a7K7UMq3jqakkC9-MlUB
  69.         [recaptcha_response_field] => peron smock
  70.         [PHPSESSID] => e5ackrv75hsi4kagssgi33ehm5
  71.     )
  72.  
  73.  */
  74. if($errors != "") {
  75.     $result = "Errors occured:<br/>" . $errors;
  76. } else {
  77.     $result = "Ok";
  78. }
  79.  
  80. echo $result;
  81. ?></code>


Vamos dale un poco de esfuerzo y asi le aprendes mejor.

Saludos
__________________
.: Gildus :.