Dax Posté 10 Janvier 2008 Posté 10 Janvier 2008 (modifié) Bonjour à tous, Lorsqu'un membre s'inscrit sur mon site, un mail contenant un lien pour confirmer son adresse email lui est envoyé, seulement il arrive parfois que ce mail ne soit pas envoyé pour des raisons que j'ignore. Ce que j'aimerai proposer c'est un code qui permette de récupérer le code de vérification présent dans la base de données et de l'envoyer de nouveau au membre qui en fait la demande. Je ne suis pas expert donc j'ai essayé de m'inspirer de ce code qui permet d'envoyer un nouveau mot de passe lorsqu'un membre a oublié le sien, mais aussi de se connecter à son espace membre. CODE <?$msg = ""; if (isset($_GET["logout"])) { session_start(); $_SESSION = array(); session_destroy(); } else session_start(); include_once("admin/inc.php"); $pagename = $sitename . " - " . LA_LOGIN; include_once("header_inc.php"); writeLinkedTitle(""); if ($auto) include "update.php"; if (!empty($_SESSION["valid_user"])) { echo "<blockquote><p><b>" . LA_ALREADY_LOGGED . "</b><br>"; echo LA_ALREADY_LOGGED_DESC . "</p></blockquote>"; include("footer_inc.php"); exit; } if (empty($set_outer_color)) { $set_outer_color = "#A9B8D1"; } if (empty($set_inner_color)) { $set_inner_color = "#FFFFFF"; } if (empty($set_descr_color)) { $set_descr_color = "#FFFFFF"; } if (isset($_POST["submit"]) AND !isset($_REQUEST["forgot"])) { $username=""; $password=""; if (isset($_POST["username"])) $username = htmlspecialchars($_POST["username"]); if (isset($_POST["password"])) $password = htmlspecialchars($_POST["password"]); $username=trim(getParam("username","")); $password=trim(getParam("password","")); $sql = "select user_status,user_verify_code,user_approved,user_id,user_name,user_email from $usr_tbl where user_email = '$username' AND user_pass_md5 = md5('$password')"; $result = q($sql); $num_check = mysql_num_rows($result); if ($num_check==1) { $row_line = mysql_fetch_array($result); $status = $row_line["user_status"]; $verify_code = $row_line["user_verify_code"]; $approve = $row_line["user_approved"]; $user_id = $row_line["user_id"]; $user_email = $row_line["user_email"]; $name = $row_line["user_name"]; if ($status == 1) $msg = LA_BLOCKED_LOGIN; elseif ($verify_code AND $opt_verify) $msg = LA_NEED_TO; elseif ($approve_mem AND !$approve) $msg = LA_WAIT_APP; else { $_SESSION["valid_user"] = $user_id; $_SESSION["user_name"] = $name; $_SESSION["user_email"] = $user_email; addLoginItem($user_id); addToHistory(1,$user_id,"",""); // Redirect user to correct page if (!empty($_REQUEST["redirect_to"])) redirect($_REQUEST["redirect_to"]); else redirect("member.php"); } } else { // Failed login //$msg = writeHeadLine(LA_WARNING,"red"); $msg = $msg . LA_NOT_AUTHORIZED; addToHistory(13,"","","$username"); } } elseif (isset($_REQUEST["forgot"]) AND isset($_POST["email"])) { $email = $_POST["email"]; $new_password = generatePassword(5); if (($email)) { $result = q ("select user_email from $usr_tbl where user_email = '$email'"); $count_results = mysql_num_rows($result); if ($count_results>0) { $sql="update $usr_tbl set user_pass_md5 = md5('$new_password') where user_email = '$email'"; $res = q ($sql); $msg = writeHeadLine(LA_SUCCESS,"black"); $msg = $msg . formatString(LA_FORGOT_SENT_MSG,array("<b>$email</b>")); addToHistory(14,"","","$username"); sendEmail($email,$from_adress_mail,LA_FORGOT_MAIL_SUBJECT,formatString(LA_FORGOT_SEND_MAIL_BO DY, array("$new_password","http://$url/member_login.php","$name_of_site"))); } else { $msg = writeHeadLine(LA_WARNING,"red"); $msg = $msg . formatString(LA_FORGOT_NOTF,array("<b>$email</b>")); } } else { $msg = writeHeadLine(LA_WARNING,"red"); $msg = $msg . LA_ERROR_MSG21; } } if (isset($_REQUEST["logout"])) { $msg = $la_session_remove; } check_valid_user("$msg"); require("footer_inc.php"); ?> Voici le code que j'ai inventé (je pense que j'aurai plus de chance de gagner au loto que trouver un code qui marche mais bon...) et forcément il ne marche pas, auriez vous une direction à me donner SVP parceque là je désespère. Je voudrai récupérer le "user_verify_code". CODE <?$msg = ""; include_once("admin/inc.php"); $pagename = $sitename . " - " . LA_LOGIN; include_once("header_inc.php"); if (isset($_REQUEST["forgot"]) AND isset($_POST["user_name"])) { $user_name = $_POST["user_name"]; $user_verify_code = $row["user_verify_code"]; if (($user_name)) { $mysql_user = "select user_name, user_verify_code from $usr_tbl"; $result = q ($mysql_user); $num_check = mysql_num_rows($result); if ($num_check==1) { $sql="select user_verify_code from $usr_tbl"; $res = q ($sql); $msg = writeHeadLine(LA_SUCCESS,"black"); $msg = $msg . formatString(LA_VERIFYCODE_SENT_MSG,array("<b>$user_name</b>")); sendEmail($email,$from_adress_mail,LA_VERIFYCODE_SUBJECT,formatString(LA_VERIFYCODE_SEND_MAIL _BODY, array("http://$url/verify.php?=","$user_verify_code"))); } else { $msg = writeHeadLine(LA_WARNING,"red"); $msg = $msg . formatString(LA_VERIFYCODE_NOTF,array("<b>$user_name</b>")); } } else { $msg = writeHeadLine(LA_WARNING,"red"); $msg = $msg . LA_ERROR_MSG_VERIFYCODE; } } if (isset($_REQUEST["logout"])) { $msg = $la_session_remove; } check_valid_user("$msg"); require("footer_inc.php"); ?> Si çà peut vous guider voici aussi le code qui permet l'inscription CODE <?session_start(); include("admin/inc.php"); $lBanList = split(",", $set_banlist_users); $catname = " :: $register"; include("header_inc.php"); $FName = getParam("friendname",""); $FEmail = trim(getParam("friendemail","")); $lEmail = trim(getParam("email","")); $lName = getParam("name",""); $lPassOne=getParam("passwd",""); $lPassTwo=getParam("passwd2",""); $lEmelding=getParam("emelding",""); $lValidateSign=getParam("validate_sign",""); $lHideEmail=getParam("hide_email",""); $lAgreeCond=getParam("agree_cond",""); $tplRegister=new TplLoad; writeLinkedTitle(""); if (isset($_SESSION["valid_user"])) { echo "<blockquote><p class='box'>".LA_ALREADY_LOGGED_DESC."</p></blockquote>"; include("footer_inc.php"); exit; } $lExtraFieldArray=getMandatoryValues("",2); $i=0; if (is_array($lExtraFieldArray)) { foreach ($lExtraFieldArray as $item) { $value="e_" . $item["q_field"]; $lArray[$i]["id"]=$i; $lArray[$i]["field"]=$value; $lStr=$_REQUEST[$value]; $lValueStr=""; if ($lStr) { if (is_array($lStr)) { foreach ($lStr as $lItem) $lValueStr.="$lItem,"; $lValueStr=substr($lValueStr,0,-1); } else $lValueStr=$lStr; } elseif (getParam("submit","")=="") { $lValueStr=$row[$value]; } if (getParam("submit","") !="") { if ($item["q_mand"] && empty($lValueStr)) $error_str.= "<li class='warn_intend'>".LA_YOU_MUST ." <b>" . $item["q_question"] . "</b></li>"; else if (!empty($item["q_reg_exp"])) { if (preg_match($item["q_reg_exp"],$lValueStr)) $error_str.="<li class='warn_intend'>".$item["q_reg_exp_errormsg"] ." <b>".$item["q_question"]."</b></li>"; } } $lArray[$i]["value"]=$lValueStr; $data.="$value='$lValueStr',"; $i++; } $lExtraArray=getExtraAdvValue("",2,$lArray); $tplRegister->assign("extra_fields_array",$lExtraArray); } if (isset($_POST["submit"])) { $result = mysql_query ("select * from $usr_tbl where user_email = '$lEmail'"); if (mysql_num_rows($result)>0) $error_str.= "<li type='square' class='warn_intend'>".LA_ERROR_MSG20."</li>"; if (!validEmail($lEmail)) $error_str.= "<li type='square' class='warn_intend'>".LA_ERROR_MSG21."</li>"; if (ereg(" ", $lPassOne) OR strlen($lPassOne)<$set_password_len) $error_str.= "<li type='square' class='warn_intend'>". ereg_replace("%1%",$set_password_len,LA_ERROR_MSG24)."</li>"; if (($lPassOne <> $lPassTwo)) $error_str.= "<li type='square' class='warn_intend'>".LA_ERROR_MSG22."</li>"; if (($set_agree_conditions==1 AND !$lAgreeCond)) $error_str.= "<li type='square' class='warn_intend'>".LA_CONDITIONS_MANDATORY ."</li>"; if (($set_img_validation==1 AND $_SESSION["validate_sign_session"] <> $lValidateSign)) $error_str.= "<li type='square' class='warn_intend'>".LA_IMG_VER_FAILED ."</li>"; if ($usr_1_mandatory AND $usr_1 == "") $error_str.= "<li type='square' class='warn_intend'>".LA_FIELD." $usr_1_text ". LA_MAND ."</li>"; // Find Extra fields in user table and get values from not empty rows $i=0; $lRemoteIP=getRemoteIp(); if (!empty($lEmail)) $error_str.=ban($lBanList, $lEmail); if (!empty($lRemoteIP)) $error_str.=ban($lBanList, getRemoteIp()); //getRemoteIp if (!$error_str) { $temp_validate = ""; if ($opt_verify) { $temp_validate = generatePassword(5); } else { $random = 0; } $registered = time(); if (!$opt_verify) { $p = ""; } else { $p = $lPassOne; } $user_id=createUser($lEmail,$lPassOne,$lName,$lEmelding,$lHideEmail,$temp_validate,$data); if ($result) { $tplRegister=new TplLoad; $tplRegister->assign("registration_ok",1); if ($set_payments) { $sql="select count(pid) as num from $pkg_tbl"; $res_count=q($sql); $row_c=mysql_fetch_array($res_count); $num_packages=$row_c["num"]; // Create new admin user if admin table is empty if ($num_packages<1) { q("INSERT INTO `$pkg_tbl` (`pid`, `pname`, `pterm`, `pdur`, `pactive`, `pprice`, `pcurrency`, `pupload`, `pmessages`, `pchat`, `pgb`, `protation`, `pvisitor`, `pfav`, `pmatch`, `pflirts`) VALUES (99, 'Default', 1, 3, 2, 0.00, 'USD', 3, 4, 999, 1, 1, 10, 10, 10, 10)"); q("INSERT INTO `$pkg_tbl` (`pid`, `pname`, `pterm`, `pdur`, `pactive`, `pprice`, `pcurrency`, `pupload`, `pmessages`, `pchat`, `pgb`, `protation`, `pvisitor`, `pfav`, `pmatch`, `pflirts`) VALUES (1, 'Small', 2, 30, 1, 10.00, 'USD', 5, 20, 999, 1, 1, 1, 30, 30, 30)"); q("INSERT INTO `$pkg_tbl` (`pid`, `pname`, `pterm`, `pdur`, `pactive`, `pprice`, `pcurrency`, `pupload`, `pmessages`, `pchat`, `pgb`, `protation`, `pvisitor`, `pfav`, `pmatch`, `pflirts`) VALUES (2, 'Medium', 1, 60, 1, 25.00, 'USD', 25, 250, 999, 1, 1, 55, 55, 55, 55)"); q("INSERT INTO `$pkg_tbl` (`pid`, `pname`, `pterm`, `pdur`, `pactive`, `pprice`, `pcurrency`, `pupload`, `pmessages`, `pchat`, `pgb`, `protation`, `pvisitor`, `pfav`, `pmatch`, `pflirts`) VALUES (3, 'Gold', 1, 90, 1, 60.00, 'USD', 200, 200, 999, 1, 1, 200, 200, 200, 200)"); } addPackage($user_id,99); } if ($opt_verify) { $subject = formatString(LA_NEW_USER_MAIL_TITLE, array("$name_of_site")); $message = formatString(LA_NEW_USER_MAIL_MSG_VAL . LA_NEW_USER_MAIL_MSG2_VAL, array("http://$url/verify.php?verify=$temp_validate","$name_of_site")); sendEmail($lEmail, $from_adress_mail, $subject, $message); //Friend Invite: if ($FName != "" || $FEmail !="") { $Fsubject = formatString(LA_FRIEND_MAIL_TITLE, array("$lName","$name_of_site")); $Fmessage = formatString(LA_FRIEND_MAIL_MSG, array("$lName","http://www.isula-web.com/annonces_autos_voitures_vehicules_occasion","Isula Web","$FName")); sendEmail($FEmail, $lEmail, $Fsubject, $Fmessage); } $tplRegister->assign("verify",1); } elseif ($approve_mem) { //$sql = "update $usr_tbl set months='" .round($_REQUEST["months"]) ."' where user_id=$user_id"; //$r = q($sql); $tplRegister->assign("wait_approval",1); } else { $subject = formatString(LA_NEW_USER_MAIL_TITLE, array("$name_of_site")); $message = formatString(LA_NEW_USER_MAIL_MSG . LA_NEW_USER_MAIL_MSG2, array("http://$url/member_login.php","$lEmail","$lPassOne","$name_of_site")); sendEmail($lEmail, $from_adress_mail, $subject, $message); $_SESSION["valid_user"] = $user_id; addLoginItem($user_id); } } } } if (!isset($_POST["submit"]) OR (isset($_POST["submit"]) AND !empty($error_str))) { $tplRegister->assign("show_regform",1); $tplRegister->caching = false; $tplRegister->assign("name",getParam("name","")); $tplRegister->assign("email",getParam("email","")); $tplRegister->assign("passwd",getParam("passwd","")); $tplRegister->assign("passwd2",getParam("passwd2","")); $tplRegister->assign("emelding",getParam("emelding","")); $tplRegister->assign("hide_email",getParam("hide_email","")); $tplRegister->assign("agree_cond",getParam("agree_cond","")); $tplRegister->assign("la_pass",eregi_replace("%1%",$set_password_len,LA_PASS1)); $tplRegister->assign("set_agree_conditions",$set_agree_conditions); $tplRegister->assign("LA_CONDITIONS_TEXT",formatString(LA_CONDITIONS,array("<a href=\"java script:openWin3('info.php?what=terms',300,500,'')\">"))); if ($error_str) $error_str="<ul class='warn'>$error_str</ul>"; $tplRegister->assign("errorMsg",$error_str); if ($set_img_validation==1) $tplRegister->assign("image_validation",1); } $tplRegister->display("register.tpl"); include_once("footer_inc.php"); ?> Modifié 10 Janvier 2008 par Dax
Dax Posté 10 Janvier 2008 Auteur Posté 10 Janvier 2008 J'ai aussi essayé ce petit code qui devrait permettre de créer un fichier xml contenant le nom des membres suivis de leurs codes de confirmation respectifs, seulement il commence à créer le fichier puis bloque à cause d'une erreur. Voici ce qui est affiché lorsque je consulte le fichier xml, seul le dernier membre apparait et pas les autres: Un nom contenait un caractère non valide. Erreur de traitement de la ressource http://www.monsite.com/verification.xml <Verify code><user><name>Dax</name><code>1938ereWJ</code></user> ------------^ <?include_once("admin/inc.php"); $writeStr=""; $writeStr.="<Verify code>"; $mysql_user = "select user_name, user_verify_code from $usr_tbl"; $result = q ($mysql_user); while ($row=mysql_fetch_array($result)) { $user_name = $row["user_name"]; $user_verify_code = $row["user_verify_code"]; $writeStr.="<user><name>$user_name</name><code>$user_verify_code</code></user>\n"; } $writeStr.="</Verify code>\n"; $fp = fopen("verification.xml","w+"); fwrite($fp,$writeStr); fclose($fp);?> Si je pouvais afficher tous les codes il me serait facile d'envoyer de nouveau les liens de confirmations, auriez vous une idée du pourquoi çà coince ?
fingolfin Posté 14 Janvier 2008 Posté 14 Janvier 2008 J'ai l'impression que tu te compliques la vie, tu veux t'amuser à sélectionner tout les codes de validation / activation des membres pour renvoyer celui d'un seul membre à ce membre en question, tu ne trouves pas ça un peu bête ? En gros ce que tu dois faire c'est demander le pseudo du membre dans un formulaire, une fois cela fait il ne te reste qu'à sélectionner dans la Base De Donnée le code de validation de celui-ci selon son pseudo avec une requête toute bête du genre : <?php$usr_tbl = 'membre';$pseudo = mysql_real_escape_string(htmlspecialchars(trim($_POST['pseudo'])));$req = mysql_query("SELECT user_verify_code AS code FROM $usr_tbl WHERE pseudo = '" . strtolower($pseudo) . "'")or die(mysql_error());$donnee _membre = mysql_fetch_assoc($req);$code_validation = $donnee_membre['code'];?> Enfin si du moins j'ai bien compris ton problème qui est donc de renvoyer un code d'activation à une personne précise et non d'envoyer tout les codes à tout le monde.
Sujets conseillés
Veuillez vous connecter pour commenter
Vous pourrez laisser un commentaire après vous êtes connecté.
Connectez-vous maintenant