Foros del Web » Programando para Internet » PHP »

tengo un formulario de usuario y password

Estas en el tema de tengo un formulario de usuario y password en el foro de PHP en Foros del Web. aver como puedo hacer que en los campos de usuario y password genere automatico un usuario y password...
  #1 (permalink)  
Antiguo 22/05/2011, 18:51
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 7 meses
Puntos: 5
tengo un formulario de usuario y password

aver como puedo hacer que en los campos de usuario y password
genere automatico un usuario y password
  #2 (permalink)  
Antiguo 22/05/2011, 18:56
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: tengo un formulario de usuario y password

Y ¿qué haz hecho de php?
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos
  #3 (permalink)  
Antiguo 22/05/2011, 18:59
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 7 meses
Puntos: 5
Respuesta: tengo un formulario de usuario y password

<td width="350" height="15">
<form id="adduser" name="adduser" action="adduser.php" method="post">
<?php
if (isset($_POST["username"]) and $_POST["badduser"] == "Add user and stay" and $userexists == "false" and $nouserpass == "false" and $clearfields == "false" and $createpassword == "false") {
print("<font color=\"#347C2C\">User ".$_POST["username"]." successfully added!</font><br><br>");
}
if ($userexists == "true" and $createpassword == "false") {
print("<font color=\"#FF0000\">El Usuario ya Existe!</font><br><br>");
}
if ($nouserpass == "true") {
print("<font color=\"#FF0000\">Debe introducir un nombre de usuario y una contraseña!</font><br><br>");
}
?>
Nombre:<br>
<input type="text" name="username" size="20" tabindex="1" value="<?php if ($userexists == "true" or $nouserpass == "true" or $username<>"") { print($username); } ?>" >&nbsp;<?php if($hidehelp == "0") { print("<img src=\"images/help.png\" onMouseover=\"document.getElementById('cspinfo').i nnerHTML = '".$infoname."';\" onMouseout=\"document.getElementById('cspinfo').in nerHTML = '';\">"); } ?><br><br>
Contraseña:<br>
<input type="text" name="password" size="20" tabindex="2" value="<?php if ($userexists == "true" or $nouserpass == "true" or $password<>"") { print($password); } ?>">&nbsp;<?php if($hidehelp == "0") { print("<img src=\"images/help.png\" onMouseover=\"document.getElementById('cspinfo').i nnerHTML = '".$infopassword."';\" onMouseout=\"document.getElementById('cspinfo').in nerHTML = '';\">"); } ?><br><br>
Nombre del Cliente:<br>
<input type="text" name="displayname" size="20" tabindex="3" value="<?php if ($userexists == "true" or $nouserpass == "true" or $displayname<>"") { print($displayname); } ?>">&nbsp;<?php if($hidehelp == "0") { print("<img src=\"images/help.png\" onMouseover=\"document.getElementById('cspinfo').i nnerHTML = '".$infodisplayname."';\" onMouseout=\"document.getElementById('cspinfo').in nerHTML = '';\">"); } ?><br><br>
Correo:<br>
<input type="text" name="email" size="20" tabindex="5" value="<?php if ($userexists == "true" or $nouserpass == "true" or $email<>"") { print($email); } ?>">&nbsp;<?php if($hidehelp == "0") { print("<img src=\"images/help.png\" onMouseover=\"document.getElementById('cspinfo').i nnerHTML = '".$infoemail."';\" onMouseout=\"document.getElementById('cspinfo').in nerHTML = '';\">"); } ?><br><br>
Meses: <b><font color="#FF0000"><u>1</u></font></b> Mes <br><br>
<fieldset>
<legend class="addedit">Servicios(s):&nbsp;&nbsp;<?php if($hidehelp == "0") { print("<img src=\"images/help.png\" onMouseover=\"document.getElementById('cspinfo').i nnerHTML = '".$infoprofiles."';\" onMouseout=\"document.getElementById('cspinfo').in nerHTML = '';\">"); } ?><br></legend>
<table width="100%" valign="top" cellpadding="0" cellspacing="0">
<?php
if ($usedefaults == "true" and $userexists == "false") {
$lr = "0";
$conn2 = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
mysql_select_db($dbname, $conn2);
$sql2 = mysql_query("SELECT * FROM cmum_profiles") or die ("Error selecting database");
$sql3 = mysql_query("SELECT * FROM cmum_settings WHERE id='1'") or die ("Error selecting database");
$numprof = mysql_num_rows($sql2);
$line3=mysql_fetch_array($sql3);
while($line2=mysql_fetch_array($sql2)) {
if ($lr == "0") {
$dbprof = unserialize($line3["def_profiles"]);
if ($dbprof <> "") {
$checked = "";
foreach($dbprof as $printprof) {
if ($printprof == $line2["id"]) {
$checked = "checked=\"checked\"";
}
}
} else {
$checked = "";
}
print("<tr width=\"100%\" valign=\"top\"><td width=\"50%\" valign=\"top\"><input type=\"checkbox\" name=\"profiles[]\" tabindex=\"12\" value=\"".$line2["id"]."\" ".$checked."/>".$line2["name"]."</td>");
$lr = "1";
} else {
$dbprof = unserialize($line3["def_profiles"]);
if ($dbprof <> "") {
$checked = "";
foreach($dbprof as $printprof) {
if ($printprof == $line2["id"]) {
$checked = "checked=\"checked\"";
}
}
} else {
$checked = "";
}
print("<td width=\"50%\" valign=\"top\"><input type=\"checkbox\" name=\"profiles[]\" tabindex=\"12\" value=\"".$line2["id"]."\" ".$checked."/>".$line2["name"]."</td></tr>");
$lr = "0";
}
}
mysql_close($conn2);
}
if ($userexists == "true" and $usedefaults == "false") {
$lr = "0";
$conn2 = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
mysql_select_db($dbname, $conn2);
$sql2 = mysql_query("SELECT * FROM cmum_profiles") or die ("Error selecting database");
$numprof = mysql_num_rows($sql2);
while($line2=mysql_fetch_array($sql2)) {
if ($lr == "0") {
$dbprof = unserialize($profiles);
if ($dbprof <> "") {
$checked = "";
foreach($dbprof as $printprof) {
if ($printprof == $line2["id"]) {
$checked = "checked=\"checked\"";
}
}
} else {
$checked = "";
}
print("<tr width=\"100%\" valign=\"top\"><td width=\"50%\" valign=\"top\"><input type=\"checkbox\" name=\"profiles[]\" tabindex=\"12\" value=\"".$line2["id"]."\" ".$checked."/>".$line2["name"]."</td>");
$lr = "1";
} else {
$dbprof = unserialize($profiles);
if ($dbprof <> "") {
$checked = "";
foreach($dbprof as $printprof) {
if ($printprof == $line2["id"]) {
$checked = "checked=\"checked\"";
}
}
} else {
$checked = "";
}
print("<td width=\"50%\" valign=\"top\"><input type=\"checkbox\" name=\"profiles[]\" tabindex=\"12\" value=\"".$line2["id"]."\" ".$checked."/>".$line2["name"]."</td></tr>");
$lr = "0";
}
}
mysql_close($conn2);
}
if ($userexists == "true" and $usedefaults == "true") {
$lr = "0";
$conn2 = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
mysql_select_db($dbname, $conn2);
$sql2 = mysql_query("SELECT * FROM cmum_profiles") or die ("Error selecting database");
$numprof = mysql_num_rows($sql2);
while($line2=mysql_fetch_array($sql2)) {
if ($lr == "0") {
$dbprof = unserialize($profiles);
if ($dbprof <> "") {
$checked = "";
foreach($dbprof as $printprof) {
if ($printprof == $line2["id"]) {
$checked = "checked=\"checked\"";
}
}
} else {
$checked = "";
}
print("<tr width=\"100%\" valign=\"top\"><td width=\"50%\" valign=\"top\"><input type=\"checkbox\" name=\"profiles[]\" tabindex=\"12\" value=\"".$line2["id"]."\" ".$checked."/>".$line2["name"]."</td>");
$lr = "1";
} else {
$dbprof = unserialize($profiles);
if ($dbprof <> "") {
$checked = "";
foreach($dbprof as $printprof) {
if ($printprof == $line2["id"]) {
$checked = "checked=\"checked\"";
}
}
} else {
$checked = "";
}
print("<td width=\"50%\" valign=\"top\"><input type=\"checkbox\" name=\"profiles[]\" tabindex=\"12\" value=\"".$line2["id"]."\" ".$checked."/>".$line2["name"]."</td></tr>");
$lr = "0";
}
}
mysql_close($conn2);
}
if ($userexists == "false" and $usedefaults == "false") {
$lr = "0";
$conn2 = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
mysql_select_db($dbname, $conn2);
$sql2 = mysql_query("SELECT * FROM cmum_profiles") or die ("Error selecting database");
$numprof = mysql_num_rows($sql2);
while($line2=mysql_fetch_array($sql2)) {
if ($lr == "0") {
print("<tr width=\"100%\" valign=\"top\"><td width=\"50%\" valign=\"top\"><input type=\"checkbox\" name=\"profiles[]\" tabindex=\"12\" value=\"".$line2["id"]."\"/>".$line2["name"]."</td>");
$lr = "1";
} else {
print("<td width=\"50%\" valign=\"top\"><input type=\"checkbox\" name=\"profiles[]\" tabindex=\"12\" value=\"".$line2["id"]."\"/>".$line2["name"]."</td></tr>");
$lr = "0";
}
}
mysql_close($conn2);
}
?>
</table>
<?php
if ($numprof == 0) {
print("No profiles added!");
} else {
print("<br><input type=\"checkbox\" name=\"allprof\" onClick=\"checkedAll(adduser)\">Todos");
}
?>
</fieldset>
Comentario:<br>
<textarea name="comment" cols="50" rows="6" tabindex="14"><?php if ($userexists == "true" or $nouserpass == "true" or $comment<>"") { print($comment); } ?></textarea>
<br><br>
<input type="submit" name="badduser" value="Agregar" tabindex="15" class="submit" accesskey="s" title="(ALT+S)">
<input type="submit" name="badduser" value="Limpiar" tabindex="19" class="submit" accesskey="c" title="(ALT+C)" onClick="focus();adduser.username.focus()">
</form>
<?php
$conn = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
mysql_select_db($dbname, $conn);
$sql2 = mysql_query("SELECT * FROM cmum_dealer WHERE username='".$_SESSION["loginuser"]."'");
$cred=mysql_fetch_array($sql2);
mysql_close($conn);
?>Creditos Disponibles: <b><font color="#FF0000">( <u><?php print($cred["creditos"]); ?></u> )</font> </b>
</td>
<td width="370" height="20" valign="top"><div id="cspinfo" style="width: 230px"></div></td>
<td width="12" height="20" valign="top">&nbsp;</td>
  #4 (permalink)  
Antiguo 22/05/2011, 19:24
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 7 meses
Puntos: 5
Respuesta: tengo un formulario de usuario y password

consegui esto <?php
function
genera_password($longitud,$tipo="alfanumerico")
{
if ($tipo=="alfanumerico"){
$rando="[^A-Z0-9]";
}
return substr(eregi_replace($rando, "", md5(rand())),
0, $longitud);
}

echo "".genera_password(8)."";
?>

pero me tira eror

Deprecated: Function eregi_replace() is deprecated
y como puedo implementarlo en el fomulariodel user y pass
  #5 (permalink)  
Antiguo 22/05/2011, 19:36
 
Fecha de Ingreso: septiembre-2007
Ubicación: PyRoot
Mensajes: 1.515
Antigüedad: 16 años, 7 meses
Puntos: 188
Respuesta: tengo un formulario de usuario y password

Hace algunos años me encontré con esté código por internet, a mi me sirvió mucho en aquellos tiempos en los que no comprendia bien PHP.

La función genera una cadena alfanumerica

Código PHP:
Ver original
  1. <?php
  2. function RandomString($length=10,$uc=TRUE,$n=TRUE,$sc=FALSE)
  3. {
  4.     $source = 'abcdefghijklmnopqrstuvwxyz';
  5.     if($uc==1) $source .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  6.     if($n==1) $source .= '1234567890';
  7.     if($sc==1) $source .= '|@#~$%()=^*+[]{}-_';
  8.     if($length>0){
  9.         $rstr = "";
  10.         $source = str_split($source,1);
  11.         for($i=1; $i<=$length; $i++){
  12.             mt_srand((double)microtime() * 1000000);
  13.             $num = mt_rand(1,count($source));
  14.             $rstr .= $source[$num-1];
  15.         }
  16.  
  17.     }
  18.     return $rstr;
  19. }
  20. ?>

por medio de este llamado determinas con que caracteristicas quieres tu cadena de texto:
Código PHP:
Ver original
  1. <?php echo RandomString(15,TRUE,TRUE,TRUE); ?>

RandomString(Tamaño de la cadena, LETRAS MAYUSCULAS, numeros, caracteres especiales)

cambias el TRUE por FALSE dado el caso que quieras desactivar la opción para cada caso respectivamente.
  #6 (permalink)  
Antiguo 23/05/2011, 05:26
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 7 meses
Puntos: 5
Respuesta: tengo un formulario de usuario y password

ok perfecto me funciono de mucho utilidad

Etiquetas: password, formulario, usuarios
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 03:32.