NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page 250np$ For simple php script

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 10-26-2004, 04:34 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
QBert's Avatar
Join Date: Apr 2004
Location: Australia
Posts: 814
QBert is just really niceQBert is just really niceQBert is just really niceQBert is just really nice
 


Save a Life Alzheimer's Breast Cancer

250np$ For simple php script


Hey, i need a script that checkes a value what somones typed up to see if its = to somthing in the database. just like checking for a username to put to a password.

Thanks

QBert
QBert is offline  
Old 10-26-2004, 05:54 PM   #2 (permalink)
Senior Member
 
Crusader's Avatar
Join Date: Aug 2003
Location: Canada
Posts: 1,257
Crusader is just really niceCrusader is just really niceCrusader is just really niceCrusader is just really nice
 



This would be form.html
Code:
<form name="checker" method="POST" action="domain.com/check.php">
  <p>Username: <input type="text" name="username" size="20" value="<?php echo $username; ?>"><br>
  <input type="submit" value="Check" name="doit"></p>
</form>
This would be check.php
PHP Code:
<?php

$username 
$_POST['username'];

if(
$username != " "){
    
$username str_replace("<?""&nbsp;"$username);
    
$username str_replace("?>""&nbsp;"$username);
    
    
$sql_username_check mysql_query("SELECT username FROM usernames WHERE username='$username'");
????: NamePros.com http://www.namepros.com/programming/53172-250np-for-simple-php-script.html
????: NamePros.com http://www.namepros.com/showthread.php?t=53172
    
$username_check mysql_num_rows($sql_username_check);

     if(
$username_check 0){
         echo 
"That username already exists.";
         unset(
$username);
     } else {
        echo 
"That username does not exist.";
    }
}

include (
"form.html");

?>
I think that should work. Note you'd need a table called usernames with a field called username.
Crusader is offline  
Old 10-26-2004, 06:28 PM   #3 (permalink)
Senior Member
 
PolurNET's Avatar
Join Date: Jul 2004
Location: I ♥ Business Law
Posts: 3,082
PolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant future
 

Member of the Month
January 2007
Alzheimer's Cancer Survivorship Third World Education Autism Save a Life Cystic Fibrosis Parkinson's Disease Lou Gehrig's Disease (ALS) Autism Multiple Sclerosis SIDS
remember to connect to a DB first m8, you need to use

Code:
mysql_connect('localhost', 'mydb', 'mypass');
PolurNET is offline  
Old 10-26-2004, 06:34 PM   #4 (permalink)
québécois libre
 
peaudecastor's Avatar
Join Date: Oct 2003
Location: Trois-Rivieres, Québec
Posts: 558
peaudecastor is just really nicepeaudecastor is just really nicepeaudecastor is just really nicepeaudecastor is just really nicepeaudecastor is just really nicepeaudecastor is just really nicepeaudecastor is just really nicepeaudecastor is just really nice
 



Hi Crusader,

Why are you checking for <? and ?> ?
PHP Code:
$username = str_replace("<?", "&nbsp;", $username);
Unless you prove me otherwise they are harmless what you should always do to be secure are :
$username = addslashes($username);

With your code I could post in the username field something like '; DELETE FROM usernames

And break you

Matt

Originally Posted by Crusader
This would be form.html
Code:
<form name="checker" method="POST" action="domain.com/check.php">
  <p>Username: <input type="text" name="username" size="20" value="<?php echo $username; ?>"><br>
  <input type="submit" value="Check" name="doit"></p>
</form>
This would be check.php
????: NamePros.com http://www.namepros.com/showthread.php?t=53172
PHP Code:
<?php

$username 
$_POST['username'];

if(
$username != " "){
    
$username str_replace("<?""&nbsp;"$username);
    
$username str_replace("?>""&nbsp;"$username);
    
    
$sql_username_check mysql_query("SELECT username FROM usernames WHERE username='$username'");
    
$username_check mysql_num_rows($sql_username_check);

     if(
$username_check 0){
         echo 
"That username already exists.";
         unset(
$username);
     } else {
        echo 
"That username does not exist.";
    }
}

include (
"form.html");
????: NamePros.com http://www.namepros.com/showthread.php?t=53172

?>
I think that should work. Note you'd need a table called usernames with a field called username.
peaudecastor is offline  
Old 10-26-2004, 06:36 PM   #5 (permalink)
Senior Member
 
Crusader's Avatar
Join Date: Aug 2003
Location: Canada
Posts: 1,257
Crusader is just really niceCrusader is just really niceCrusader is just really niceCrusader is just really nice
 



Err. Yeah, you're right. Ignore the <? ?> and strip out special characters instead.
Crusader is offline  
Old 10-26-2004, 10:50 PM THREAD STARTER               #6 (permalink)
NamePros Regular
 
QBert's Avatar
Join Date: Apr 2004
Location: Australia
Posts: 814
QBert is just really niceQBert is just really niceQBert is just really niceQBert is just really nice
 


Save a Life Alzheimer's Breast Cancer
Thanks everyone,

NP$'s sent Crusader. Thanks!
QBert is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 02:34 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger