I just looked over the code I recently submitted.. the last if statement needs a semi-colon at the end of the echo("The name don't exist") part... sory if you copy/pasted and got an error.. ;) "Gimic" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It's a simple algorythem, use a loop to enter the names from the database > into an array, and compare each to the value in the array. or some hybred > thereof. > > > <?php > function Compare($UserInput) { > $db=mysql_connect($ServerAddress,$LoginName,$LoginPassword)); > mysql_select_db($userDB,$db); > $result = mysql_query('Select * from ' . $TableWithNames, $db); > $rowIndex = ;/*right here enter the column in the row that your user > names are stored in */ > while ($row = mysql_fetch_row($result)) { > if ($row[$rowIndex] == $UserInput) { > return true; > } > return false; > } > mysql_close; > }/*This is the end of the function.. next you will have to > rip the user input from the post.. in this example I'll call > it $_POST["Name"] and use the function to return the > value if the function returns true then the name exists in > the database if false then it obviously don't*/ > $Name = $_POST["name"]; > $bolNames = Compare($Name); > if (bolNames == true) { > echo('The name exists'); > } > if (bolNames == false) { > echo('The name don't exist') > } > > ?> > regardless of what performance freaks say.. this won't make a big dif in > performance unless you are like yahoo with several hundred million names to > compare to.. any intrensic functions basically do this same thing. This > gives you more power though. and if you have a HUGE user base you will > prolly be running mysql on a stand alone machine away from the web server so > that the traffic don't affect db interaction. FYI the syntax may be somewhat > rough, I'm somewhat new to the syntax.. I have been coding software for > quite some time and this works for me. Good luck. > > > "Dr. Zoidberg" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Manuel Lemos wrote: > > > Hello, > > > > > > On 03/25/2004 10:19 PM, Dr. Zoidberg wrote: > > > > > >> I'm creating registration service with this great form script for > > >> creating forms within Smarty. > > >> > > >> Question is how can I validate 'username' against allready registered > > >> users in MySQL so that someone cannot register him self if there is > > >> another user with that username. > > > > > > > > > You can always use the ValidateServerFunction parameter to specify the > > > name of a callback function that will make a database query to see if > > > ise there any user name with the value passed to that function. If there > > > is a record with that user name return 0 and the class will set the > > > respective input field as invalid. > > > > I'm trying to create that for a few hours. Can you PLS give me an example?
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php