| | |
check username
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 1
Reputation:
Solved Threads: 0
Hi,
I have given you the sample code developed to to check User Name. I have done it using HTML and PHP. If you have any query feel free to contact...
SERVER SIDE SCRIPTING FILE (PHP)
Have a nice day...
Regards,
Amudhan R
I have given you the sample code developed to to check User Name. I have done it using HTML and PHP. If you have any query feel free to contact...

HTML Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript" language="javascript"> <!-- // Function returns a XML Request Object function getXMLReqObject() { var objReq = null; // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { objReq = new XMLHttpRequest(); } // branch for IE/Windows ActiveX version else if (window.ActiveXObject) { objReq = new ActiveXObject("Microsoft.XMLHTTP"); } return objReq; } var httpReq = null; var frmObj = document.frmAdd; function validateForm() { if(!chkText(frmObj.txtUserName,'User Name field is empty. Please enter value')) return false; var httpReq = getXMLReqObject(); if(httpReq) { var url = 'ajax.php?userName='+frmObj.txtUserName.value+'&userOpt=0'; httpReq.open("GET", url, false); httpReq.send(null); if (httpReq.readyState == 4) { if (httpReq.status == 200) { if(httpReq.responseText == 'Yes') { alert('User Name already exist! Please try with any other User Name'); return false; } } else { alert("There was a problem retrieving data:\n" + httpReq.statusText); return; } } } } //--> </script> </head> <body> <div> <table width="95%" border=0 align="center" cellpadding="0" cellspacing="0"> <tr> <td width="100%" align="middle"> <form method="post" name="frmAdd" id="frmAdd" action="{$smarty.server.PHP_SELF}?Opt=addUser" onSubmit="return validateForm();"> <table width="100%" border="0" align="center" cellpadding="3" cellspacing="0"> <tr> <td width="14%" valign="top"> </td> <td width="1%" valign="top"> </td> <td width="85%" align="left" valign="top">* represents mandatory </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap">User Name * </td> <td valign="top">:</td> <td align="left" valign="top"><input name="txtUserName" type="text" id="txtUserName" size="30" /></td> </tr> <tr> <td valign="top"> </td> <td valign="top"> </td> <td align="left" valign="top"> </td> </tr> <tr> <td> </td> <td valign="top"> </td> <td align="left"><input name="btnAddUser" type="submit" id="btnAddUser" value="Add User" /> </td> </tr> </table> </form></td> </tr> <tr> <td align="middle"><img src="../images/spacer.gif" height="1" width="1" border="0"></td> </tr> </table> </div> </body> </html>
SERVER SIDE SCRIPTING FILE (PHP)
PHP Syntax (Toggle Plain Text)
<?php //**** Function to check whether the User Name already exist or not ****// function chkUserName($userName, $option = 0, $orgUserName) { mysql_connect("localhost","user_name","password"); mysql_select_db("database_name"); $sql = "SELECT * FROM users WHERE UCASE(user_name) = '".strtoupper($userName)."'"; //Option for Updating if($option == 1) $sql .= " AND UCASE(user_name) != '".strtoupper($orgUserName)."' "; $result=mysql_query($sql); if($result) { if(mysql_num_rows($result) > 0) return 1; } return 0; } if($_GET) { //**** Checking User Name ****// if($_GET['userName']) { $retVal = 'No'; if(chkUserName($_GET['userName'],$_GET['userOpt'],$_GET['orgUserName'])) $retVal = 'Yes'; echo $retVal; exit(); } } ?>
Have a nice day...

Regards,
Amudhan R
![]() |
Similar Threads
- Please Very Important:How to Check with Database Values (JSP)
- Authenticate Username and Password (ASP.NET)
- Check existing users in the database (ASP)
- MYSQL/PHP variable check (MySQL)
- Doesn't check if username or email exits in database properly (ASP.NET)
- How Can I Pass A PHP Variable From One .php page to another (PHP)
- php help needed for login (PHP)
- Please check and provide solution for my code (ASP)
- php coding (PHP)
- Problem connecting to the internet (Web Browsers)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Using Microsoft.Web.Preview.dll
- Next Thread: Java and IE7
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxexample ajaxjspservlets array blackjack browser captcha captchaformproblem cart checkbox child class close codes date debugger dependent developer disablefirebug dom editor element embed engine events explorer ext file firefox flash form forms game getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl maps marquee masterpage math matrixcaptcha media mysql object onerror onmouseoutdivproblem onreadystatechange parent passing paypal pdf php position post programming prototype rated redirect runtime safari scale scriptlets scroll search security session shopping size software sources star stars stretch synchronous toggle tweet unicode variables web webservice window wysiwyg \n





