PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Codewalkers ForumsPHP RelatedPHP Coding

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 Codewalkers Forums Sponsor:
Old July 3rd, 2002, 09:38 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to russ Send a message via Yahoo to russ
User Name already being used

I have a sign up script, but if some1 picks the same username that already being used how could tell the user that that username is already being used and they should pic another? also I can sort by number like 1, 2 3 etc, but what if I want to sort by all numbers, so instead of just selecting the rows that start with 1, but select the rows with all numbers

Reply With Quote
Old July 3rd, 2002, 11:06 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: User Name already being used

For the username, simply run a sql query "SELECT id FROM users WHERE username=$username" and check if any records are returned. if none, it means that the username is free.

I'm not sure what you mean by the second request. care to elaborate?

Reply With Quote
Old July 3rd, 2002, 11:26 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to russ Send a message via Yahoo to russ
RE: User Name already being used

the second one, basicly I have a site with album reviews, I have already sorted them into letters a-z, but if I just want to view the ones by number, how would I do that? I would view them by individual numbers like 1, 2, 3 etc, but as not many bands have numbers at the start of their name, I wanted to view all numbers.

Reply With Quote
Old July 3rd, 2002, 11:40 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: User Name already being used

try :

SELECT * FROM reviews WHERE albumname >= "0" AND albumname < "a"

i'm not sure if that'd work though, totally untested..

Reply With Quote
Old July 4th, 2002, 12:01 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,308 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 30
RE: User Name already being used

for the second one you might try something like:

SELECT * FROM reviews WHERE SUBSTRING(albumname,0,1) IN ('1','2','3','4','5','6','7','8','9','0')


Reply With Quote
Old July 4th, 2002, 12:07 AM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: User Name already being used

That'd prolly work too, but it'd be much slower than my version.. if mine doesn't work try anon's, coz it'll most likely work.. i'm sure there's a much faster way though.

Reply With Quote
Old July 4th, 2002, 10:37 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: User Name already being used

Change the name of the "date" field, and if that doesn't work, insert a print(mysql_error()); after the $result = mysql_query(); and give us the error.

Reply With Quote
Old July 4th, 2002, 11:18 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to russ Send a message via Yahoo to russ
RE: User Name already being used

oh no, its adds the username okay, I'm just tring to get it to tell the user if the user name they have entered has been taken

Reply With Quote
Old July 5th, 2002, 12:17 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,308 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 30
RE: User Name already being used

Do this...change:

$sql1 = "SELECT id FROM membersdb WHERE username=$username";

if(!$HTTP_POST_VARS['username']=$username) {
echo "<b>This username is in use, please go back and pick another</b>";
exit();
}

to:

$sql1 = "SELECT id FROM membersdb WHERE username='".$HTTP_POST_VARS['username']."'";
$numrows = mysql_num_rows(mysql_query($sql1));
if($numrows > 0) {
echo "<b>This username is in use, please go back and pick another</b>";
exit();
}

Reply With Quote
Old July 5th, 2002, 12:20 AM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to russ Send a message via Yahoo to russ
RE: User Name already being used

hey thanks guys, I have tried the sortby yet, I wanna get the user name one done first, basicly I have this code, I know its completely wrong, 'cause its not working

php Code:
Original - php Code
  1.  
  2. <?php
  3. $db = @mysql_connect("$dbhost", "$dbuname", "$dbpage");
  4. if (!$db) {
  5.   echo( "<p>Unable to connect to the " .
  6.         "database server at this time.</p>" );
  7.   exit();
  8. }
  9. mysql_select_db("$dbname", $db);
  10. if (! @mysql_select_db("$dbname") ) {
  11.   echo( "<p>Unable to locate the news " .
  12.         "database at this time.</p>" );
  13.   exit();
  14. }
  15.  
  16. if($submit)
  17. {
  18.     if(!$HTTP_POST_VARS['username']) {
  19.         echo "<b>You must enter a username</b>";
  20.         exit();
  21.     }
  22.     if(!$HTTP_POST_VARS['password']) {
  23.         echo "<b>You must enter a password</b>";
  24.         exit();
  25.     }
  26.     if(!$HTTP_POST_VARS['email']) {
  27.         echo "<b>You must enter an email address</b>";
  28.         exit();
  29.     }
  30.  
  31. $sql1 = "SELECT id FROM membersdb WHERE username=$username";
  32.  
  33.     if(!$HTTP_POST_VARS['username']=$username) {
  34.         echo "<b>This username is in use, please go back and pick another</b>";
  35.         exit();
  36. }
  37.  
  38. $sql = "INSERT INTO membersdb
  39. (username, password, location, email, msn, aol,
  40. yahoo, icq, bio, bands, link, date )
  41. VALUES ('$username', '$password', '$location', '$email', '$msn', '$aol', '$yahoo', '$icq', '$bio', '$bands', '$link', now('$date'))";
  42. $result = mysql_query($sql);
  43. echo "<b>Thank you! Your information has been entered.</b>n";
  44.  
  45. }
  46.  
  47.  
  48. else
  49. {
  50. ?>

Reply With Quote
Old July 6th, 2002, 05:55 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to russ Send a message via Yahoo to russ
RE: User Name already being used

Thank you that worked, Only thing is, which happens is all my scripts, and I wondered if this could be corrected, with the exit, it exits all the html parts after the php script, so I end up with half my screen missing, is there anyway or correcting this??

Reply With Quote
Old July 6th, 2002, 06:05 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to russ Send a message via Yahoo to russ
RE: User Name already being used

okay, for the number order one, I'm tring CmdrDats first, and I get this error

Parse error: parse error, unexpected T_LNUMBER in /home/gmflp/public_html/guitar.php on line 84

heres my code

php Code:
Original - php Code
  1.  
  2. if($_GET['char']=='num'){
  3.  
  4.   if(isset($_GET['start'])){$start=$_GET['start'];}else{$start=0;}
  5.  
  6.     $result=mysql_query("select * FROM guitardb WHERE band LIKE > = "0" AND band < "a" ORDER BY band ASC LIMIT " .$start.", 50",$db);
  7.  
  8.   while($myrow=mysql_fetch_array($result)){echo "<br/>".$myrow['band']." - <a href=viewtab?action=guitar&id=".$myrow[id]." class=link>".$myrow['song']."</a>";}
  9.  
  10.  
  11.  
  12.   $query="SELECT count(*) as count FROM guitardb";
  13.  
  14.   $result=mysql_query($query);
  15.  
  16.   $row=mysql_fetch_array($result);
  17.  
  18.   $numrows=$row['count'];
  19.  
  20.  
  21.  
  22. echo "<p>";
  23.  
  24.   if($start>0){echo "<a href=?action=sortby&char=".strtoupper($_GET['char'])."&start=".($start - 50)." class=link>Previous</a> ";}
  25.  
  26.  
  27.  
  28. if($numrows > ($start + 50))
  29.  
  30.    echo("<a href=?action=sortby&char=" .strtoupper($_GET['char']). "&start=" . ($start + 50) . " class=link>Next</a>");
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. }

Reply With Quote
Old July 6th, 2002, 06:17 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,308 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 30
RE: RE: User Name already being used


Quote:
Thank you that worked, Only thing is, which happens is all my scripts, and I wondered if this could be corrected, with the exit, it exits all the html parts after the php script, so I end up with half my screen missing, is there anyway or correcting this??



You will need to remove the exit, and then put everything that should execute if the name is NOT used in an else statement. Something like this:

php Code:
Original - php Code
  1. <?
  2. $sql1 = "SELECT id FROM membersdb WHERE username='".$HTTP_POST_VARS['username']."'";
  3.  
  4. $numrows = mysql_num_rows(mysql_query($sql1));
  5. if($numrows > 0) {
  6.    echo "<b>This username is in use, please go back and pick another</b>";
  7. } else {
  8.    $sql = "INSERT INTO membersdb
  9. (username, password, location, email, msn, aol,
  10. yahoo, icq, bio, bands, link, date )
  11. VALUES ('$username', '$password', '$location', '$email', '$msn', '$aol', '$yahoo', '$icq', '$bio', '$bands', '$link', now('$date'))";
  12.    $result = mysql_query($sql);
  13.    echo "<b>Thank you! Your information has been entered.</b>n";
  14. } //end else
  15. ?>



Reply With Quote
Old July 6th, 2002, 07:27 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to russ Send a message via Yahoo to russ
RE: User Name already being used

Thank you man

Reply With Quote
Old July 15th, 2002, 08:59 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to russ Send a message via Yahoo to russ
RE: User Name already being used

I haven't been about for the past few weeks, but I'm still getting trouble with the number sort.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > User Name already being used


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap