call check if user function exist

This is a discussion on "call check if user function exist" within the PHP Forum section. This forum, and the thread "call check if user function exist are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 16th, 2007, 18:48
Up'n'Coming Member
Join Date: Jul 2006
Location: manila
Age: 28
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
call check if user function exist

How to check if username is exists or not?

thanks
Reply With Quote

  #2 (permalink)  
Old Jul 16th, 2007, 19:21
Up'n'Coming Member
Join Date: Sep 2006
Location: UK
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Re: call check if user function exist

You could use mysql_num_rows() to count the number of rows returned from a query.
I.e. If the number of rows returned is more than zero, a user exists.

The following example assumes that there is a table "users" with a column "username".

PHP: Select all

<?php


$username 
$_POST['username'];
$username htmlspecialchars($username);
$username mysql_real_escape_string($username);

/* database login details */
$db_username="username";
$db_password="password";
$database="mydatabase_db";

/* connect to database */
mysql_connect("localhost",$db_username,$db_password);
@
mysql_select_db($database) or die( "Unable to select database"); 

$query "SELECT * FROM users WHERE username = '$username'"
// pull all users from "users" table where the username equals the username supplied
$result mysql_query($query);
$numrows mysql_num_rows($result);
// number of rows returned

if ($numrows 0) {
// if there are more than zero rows, the user exists
echo("Username exists");
}
if (
$numrows == 0){
// if there are zero rows, the user doesn't exist
echo("Username does not exist");
}
else {
// if the number of rows is not zero or more, either it is an invalid format, or negative, therefore something must have gone wrong. :-)
echo("Mmmmm. Something went wrong.");
}
?>

Last edited by balaclave; Jul 16th, 2007 at 19:24.
Reply With Quote
  #3 (permalink)  
Old Jul 17th, 2007, 06:14
New Member
Join Date: Jul 2006
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to michael_1980 Send a message via MSN to michael_1980 Send a message via Yahoo to michael_1980 Send a message via Skype™ to michael_1980
Re: call check if user function exist

It is so easy as mentioned in the above thread.I am sure you know to write a query and parse the result from a table

Here is the link which will help you
http://in.php.net/manual/en/function.mysql-num-rows.php

Regards
Joseph
designersforhire.com
Reply With Quote
Reply

Tags
user exist

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call a javascriprt function from a contentplaceholder Graeme36 ASP.NET Forum 0 Oct 14th, 2007 13:53
call php function in image url csun PHP Forum 16 Aug 19th, 2007 18:49
call php function in different database csun PHP Forum 1 Aug 8th, 2007 07:17
AJAX call function melvinoyh JavaScript Forum 2 May 31st, 2006 01:02
Link to call a function riotman Classic ASP 3 Dec 1st, 2005 10:03


All times are GMT. The time now is 07:30.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43