RE: [PHP] Value Checking

From: Date: Wed, 25 Oct 2000 17:44:08 +0000
Subject: RE: [PHP] Value Checking
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-21862@lists.php.net to get a copy of this message
--checkName.php3--- <?php $userName = "john42"; /* this really comes from a form or whatever */ $getData = mysql_query("SELECT userName FROM users", $db); while($checkData = mysql_fetch_array($getData)) { if($userName == $checkData["userName"]) print("Sorry, this name is used."); else mysql_query("INSERT INTO users (userName) VALUES ('$userName')", $db); } ?> I use this method to check for a home-grown sessions-checking/tracking system. marco -----Original Message----- From: Phillip S. Baker [mailto:phillip@wordsandimages.com] Sent: Tuesday, October 24, 2000 3:33 PM To: php-general@lists.php.net Subject: [PHP] Value Checking Okay I want to run a query against the DB to see if a new user is trying to take the name of an existing user at the web site. The users are placed in a members table in a MySQL database. How would I run a simple check like this on the DB. I understand the if...else part that I would need to write. If the User matches an existing user return to previous page else run this insert script. But how would the code look for the checking query? Thanks Phillip S. Baker phillip@wordsandimages.com Words & Images 1535 Seabright Avenue, Suite 100, Santa Cruz, CA 95062 Direct Line (831) 420-2641 / Fax (831) 458-0808 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#21862) next »