Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
[PHP Help] Checking for a username in the database
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Predict" data-source="post: 112358" data-attributes="member: 3953"><p>How could you even have PHP inside the template?!</p><p>Why you no use the template class to its full potential and you should consider on stop creating more exploits for yourself.</p><p> </p><p>When coding in PHP, you should think about how you're going to do it first, well that's how I plan before I code. ;p</p><p> </p><p>So, we need a mysql query selecting the person who referred the user, however we don't want to refer that user if the user doesn't exist.</p><p> </p><p>[CODE]</p><p>$query1 = mysql_query("SELECT username FROM users WHERE username = '" . mysql_real_escape_string($_GET['user']) . "' LIMIT 1");</p><p>[/CODE]</p><p> </p><p>Now, we want to check if the user exists or not and if it does, we'll proceed.</p><p> </p><p>[CODE]</p><p>if (mysql_num_rows($query1) > 0)</p><p>{</p><p>echo 'Woo?';</p><p>}</p><p>else</p><p>{</p><p>echo 'User doesn\'t exist.'</p><p>}</p><p>[/CODE]</p><p> </p><p>Finished product</p><p> </p><p>[CODE]</p><p><?php</p><p>if (isset($_GET['user']))</p><p>{</p><p>$query1 = mysql_query("SELECT username FROM users WHERE username = '" . mysql_real_escape_string($_GET['user']) . "' LIMIT 1");</p><p> </p><p>if (mysql_num_rows($query1) > 0)</p><p>{</p><p>echo 'Woo?';</p><p>}</p><p>else</p><p>{</p><p>echo 'User doesn\'t exist.';</p><p>}</p><p>}</p><p>?></p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="Predict, post: 112358, member: 3953"] How could you even have PHP inside the template?! Why you no use the template class to its full potential and you should consider on stop creating more exploits for yourself. When coding in PHP, you should think about how you're going to do it first, well that's how I plan before I code. ;p So, we need a mysql query selecting the person who referred the user, however we don't want to refer that user if the user doesn't exist. [CODE] $query1 = mysql_query("SELECT username FROM users WHERE username = '" . mysql_real_escape_string($_GET['user']) . "' LIMIT 1"); [/CODE] Now, we want to check if the user exists or not and if it does, we'll proceed. [CODE] if (mysql_num_rows($query1) > 0) { echo 'Woo?'; } else { echo 'User doesn\'t exist.' } [/CODE] Finished product [CODE] <?php if (isset($_GET['user'])) { $query1 = mysql_query("SELECT username FROM users WHERE username = '" . mysql_real_escape_string($_GET['user']) . "' LIMIT 1"); if (mysql_num_rows($query1) > 0) { echo 'Woo?'; } else { echo 'User doesn\'t exist.'; } } ?> [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
[PHP Help] Checking for a username in the database
Top