Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 29th, 2008, 02:39 PM
sudhakararaog sudhakararaog is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 11 sudhakararaog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 4 m 30 sec
Reputation Power: 0
PHP - Validating # sign in php

my question is about validation using php. i am validating a username which a user would

enter and clicks on a image to find if that username is available. example if a user enters

abc#123 php file is reading this value as abc ONLY which i do not want instead the php file

should read as abc#123. following is the sequence of pages. please advice the solution.

first page = register.php here a user enters a username and clicks on an image to find out

if the username is available or not. using a javascript function of onclick i am reading the

value entered in the form in javascript as
=============================================
var useri = document.registrationform.username
var valueofuseri = document.registrationform.username.value

var recui = /^\s{1,}$/g;

if ((useri.value==null) || (useri.value=="") || (useri.length=="") ||

(useri.value.search(recui))> -1)
{
alert("Please Enter a User Name")
return false
}

window.open("checkusernamei.php?theusernameis="+valueofuseri, "titleforavailabilityi",

"width=680, height=275, status=1, scrollbars=1, resizeable=yes");

============================================

i have used a alert message in javascript to display the value, javascript is able to

capture all the characters entered which is abc#123

second page = checkusernamei.php = this file uses GET to read what was entered in the form.
============================================
$username = $_GET["theusernameis"];

if( $username == "" || !preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $username) )
{
echo "username is blank or has special characters";
}
============================================
the # sign is being ignored only if the image is clicked in order to check the username, if

the user enters abc#123 and clicks the submit button without clicking on the checkuser image

button then my php validation for username shows an error message.

================================================== ============
if( $username == "" || !preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $username) )
{ echo "display error message for username"; }
================================================== ============
now the problem is with clicking the image only and passing the value to checkusernamei.php

using GET method
i have also used an echo statement in checkusernamei.php as
echo "value of username is ". $username; = this displays abc and not abc#123

how can i fix this problem wherein checkusernamei.php will be able to read abc#123. also in

this checkusernamei.php file i have a select query which will read if the username already

exists in the table. presently as checkusernamei.php is reading abc ONLY the select query is

also passing abc and not abc#123

$select = "Select username from table where username = '$username'";

please advice.

thanks.

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > PHP - Validating # sign in php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway