Título: Un poco de ayuda
Publicado por: gasper70 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 <!--#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,";",";") fString=replace(fString,"<","<") fString=replace(fString,">",">") fString=replace(fString,"\","\") fString=replace(fString,"--","--") fString=replace(fString,"'","'") fString=replace(fString,CHR(34),""") fString=replace(fString,vbCrlf,"<br>") HTMLEncode=fString end function %> Esta es mi pagina de registros http://o2allpro.servegame.com:15000/register/ (http://o2allpro.servegame.com:15000/register/)
Título: Re: Un poco de ayuda
Publicado por: Feedeex en 17 Mayo 2011, 12:15 pm
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: $comprobar = comprueba_usuario($cuenta_usuario); if ($comprobar == FALSE) { echo "El usuario contiene caracteres incorrectos."; } else { echo "Todo ok"; }
Título: Re: Un poco de ayuda
Publicado por: bomba1990 en 17 Mayo 2011, 14:59 pm
esto lo consegui en san google, el equivalente de pregmatch en asp: Dim userName As String = "Neimke, Darren" If Regex.IsMatch(userName, "\d+(\.?\d+)") Then ' perform some conversion and math operations here End If
|