elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Un poco de ayuda
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Un poco de ayuda  (Leído 1,530 veces)
gasper70

Desconectado Desconectado

Mensajes: 10



Ver Perfil
Un poco de ayuda
« en: 17 Mayo 2011, 07:38 am »

bueno en post anteriores pedi ayuda para crear la pagina de registro
para mi servidor online, el cual esta usando window xp y esta montado en sql server 2000 y me ayudaron mucho, espero esta ves puedan gacerlo de nuevo


les explico: logre crear pa paginas de registro, lo ise en ASP,
cual es mi nuevo problema

los usuarios se estan registrando sin problemas pero a mi me causa problema
que ellos en sus caracteres nickname pongan sombolos como
"  _ - ?¿!"·$%&/()=? "

yo no se como restrinjir esos caracteres, me gustaria dejar que solo se pudiera usar
(A-Z , 0-9) como logro eso ?

de todas maneras dejo aca mi pagina para que la vean, y si alguno de ustes no le molesta y no le quita tiempo pueda restrinjir esos caracteres.
De antemano  Muchas Gracias


Código:
<!--#include file="dbconn.asp"--><%'¶ÔÏóÃû£ºobjConn%>
<%
dim f1,f2,f3,f4,f5,f6,f7
dim sql
dim right_if

function insertdb()
sql = "insert into member (userid,usernick,sex,passwd,id9you) values('" & f2 &"','"& f3 &"',"& f4 &",'"& f5 &"','"& f7 & "')"
objConn.Execute sql ,right_if
end function


'f1 = trim(request("id"))

f2 = trim(request.form("userid"))
f2 = replace(f2,"'","''")
'f2 = replace(f2,"""","""""")

f3 = trim(request.form("usernick"))
f3 = replace(f3,"'","''")
'f3 = replace(f3,"""","""""")

f4 = trim(request.form("sex"))
f4 = replace(f4,"'","''")
'f4 = replace(f4,"""","""""")

f5 = trim(request.form("passwd1"))
f5 = replace(f5,"'","''")
'f5 = replace(f5,"""","""""")

f6 = trim(request.form("passwd2"))
f6 = replace(f6,"'","''")

f7 = trim(request.form("id9you"))
f7 = replace(f7,"'","''")
'f7 = replace(f7,"""","""""")
CHK=HTMLEncode(Trim(Request("userid")))
errorchar=array(" ","¡¡"," ","#","`","|","%","&","","!","@","$","^","*","(",")","_","-","+","=","\","{","}","[","]",":",";","'",".","<",">","?","/","GM")
for i=0 to ubound(errorchar)
if instr(username,errorchar(i))>0 then
Response.Write "<script>alert('ÄúÊäÈëµÄÊý¾Ýº¬ÓзǷ¨×Ö·û!.');history.back();</script>"
Response.end
end if
next

if f6<>f5 then
Response.Write "<script>alert('wrong password, try again.');history.back();</script>"
Response.end
end if
function runok()%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Thank you for creating your account</title>
</head>

<body>

<form method="POST" action="reg.asp">
<input type="hidden" name="id9you" size="20" value="-1">
<table border="0" width="100%" id="table1" height="100%" bgcolor="#12377F">
<tr>
<td colspan="2" height="31">
<p align="center"><b><font size="4" face="ºÚÌå" color="#FFFFFF">your account is available</font></b></td>
</tr>
<tr>
<td width="10%" align="right"><font color="#FFFFFF">
<img border="0" src="Images/man.gif" width="93" height="110"></font></td>
<td width="89%">
<p align="center"><font color="#FFFFFF">UserName : <%=f2%><br>
Password : <%=f5%></font><p align="center"><font color="#FFFFFF">Enjoy the game</font></td>
</tr>
</table>
</form>

</body>

</html> <%
end function

function runerror1()
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Error</title>
</head>

<body>

<form method="POST" action="reg.asp">
<input type="hidden" name="id9you" size="20" value="-1">
<table border="0" width="100%" id="table1" height="100%" bgcolor="#12377F">
<tr>
<td colspan="2" height="31">
<p align="center"><b><font size="4" face="ºÚÌå" color="#FFFFFF">Failed to create account</font></b></td>
</tr>
<tr>
<td width="10%" align="right"><font color="#FFFFFF">
<img border="0" src="Images/man.gif" width="93" height="110"></font></td>
<td width="89%">
<p align="center"><font color="#FFFFFF">Try again later</font></td>
</tr>
</table>
</form>

</body>

</html> <%
end function

function runerror2()
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Error</title>
</head>

<body>

<form method="POST" action="reg.asp">
<input type="hidden" name="id9you" size="20" value="-1">
<table border="0" width="100%" id="table1" height="100%" bgcolor="#12377F">
<tr>
<td colspan="2" height="31">
<p align="center"><b><font size="4" face="ºÚÌå" color="#FFFFFF">Failed to create account</font></b></td>
</tr>
<tr>
<td width="10%" align="right"><font color="#FFFFFF">
<img border="0" src="Images/man.gif" width="93" height="110"></font></td>
<td width="89%">
<p align="center"><font color="#FFFFFF">you need to send your data<br>Try again later please</font></td>
</tr>
</table>
</form>

</body>

</html> <%
end function



function chechword()
if (IsNull(f2) or IsNull(f3) or IsNull(f4) or IsNull(f5) or IsNull(f7) or f2="" or f3="" or f4="" or f5="" or f7="") then
chechword = false
else
chechword=true
end if
end function

if (chechword()=false) then
runerror2()
else
conncreat()
rs_sql = "select * from member where userid='"& f2 &"'"  
set rs = objConn.execute(rs_sql)

if (rs.eof or rs.bof) then
'²åÈëÊý¾Ý
insertdb()

if right_if=1 then
runok()
else
response.write "insert error"
end if
else
runerror1()
end if

rs.close
set rs = nothing
connclose()
end if

response.end
function HTMLEncode(fString)
fString=replace(fString,";","&#59;")
fString=replace(fString,"<","&lt;")
fString=replace(fString,">","&gt;")
fString=replace(fString,"\","&#92;")
fString=replace(fString,"--","&#45;&#45;")
fString=replace(fString,"'","&#39;")
fString=replace(fString,CHR(34),"&quot;")
fString=replace(fString,vbCrlf,"<br>")
HTMLEncode=fString
end function
%>



Esta es mi pagina de registros
http://o2allpro.servegame.com:15000/register/


« Última modificación: 17 Mayo 2011, 07:40 am por gasper70 » En línea

Feedeex

Desconectado Desconectado

Mensajes: 173


Ver Perfil
Re: Un poco de ayuda
« Respuesta #1 en: 17 Mayo 2011, 12:15 pm »

Código:
function comprobar_usuario($cuenta_usuario) {
   $caracteres_permitidos = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   for ($i = 0; $i < strlen($cuenta_usuario); $i++) {
         if (strpos($caracteres_permitidos, substr($cuenta_usuario,$i,1)) == FALSE) {
  return false;
} else {
  return true;
}
   }
  }

Llamás a la función pasándole el parámetro que contenga el nombre de usuario. Por ejemplo:

Código:
$comprobar = comprueba_usuario($cuenta_usuario);
if ($comprobar == FALSE) {
  echo "El usuario contiene caracteres incorrectos.";
} else {
 echo "Todo ok";
}


En línea

bomba1990


Desconectado Desconectado

Mensajes: 395



Ver Perfil WWW
Re: Un poco de ayuda
« Respuesta #2 en: 17 Mayo 2011, 14:59 pm »

esto lo consegui en san google, el equivalente de pregmatch en asp:

Código
  1. Dim userName As String = "Neimke, Darren"
  2.  
  3. If Regex.IsMatch(userName, "\d+(\.?\d+)") Then
  4.     ' perform some conversion and math operations here
  5. End If
En línea

"Cuando le di de comer a los pobres me llamaron santo, pero cuando pregunte porque los pobres eran pobres me dijeron comunista"

http://sosinformatico.blogspot.com/
http://www.publisnet.com.ve
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
mmm.. un poco de ayuda
Diseño Gráfico
mastertianmat3 1 1,568 Último mensaje 18 Agosto 2005, 05:53 am
por aNexos
un poco de ayuda!!!
Programación Visual Basic
S@DiHaCk 4 1,471 Último mensaje 3 Marzo 2008, 19:57 pm
por S@DiHaCk
Un poco de ayuda
Ingeniería Inversa
Jhann22 2 2,270 Último mensaje 21 Junio 2012, 19:57 pm
por apuromafo CLS
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines