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
Password
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="Markshall" data-source="post: 77740" data-attributes="member: 1872"><p>Now I'm not sure if this is what you asked for, but I've tidied up your code and make it look a little bit more presentable.</p><p> </p><p>[PHP]<?php</p><p>session_start();</p><p> </p><p>$connection=mysql_connect("localhost","root","[PASSWORD]");</p><p>$db=mysql_select_db("uber",$connection);</p><p> </p><p>function c( $str ) {</p><p> return addslashes( @mysql_real_escape_string( $s, $connection ) );</p><p>}</p><p> </p><p>if ( isset( $_POST["changepassword"] ) )</p><p>{</p><p> $username = c( $_POST["username"] );</p><p> $password = c( $_POST["password"] );</p><p> $new = md5( c( $_POST["newpassword"] ) );</p><p> $confirm = md5( c( $_POST["confirmnewpassword"] ) );</p><p> </p><p> $userQ = @mysql_query( "SELECT * FROM `users` WHERE `username` = '" . $username . "'" );</p><p> if ( @mysql_num_rows( $userQ ) == 0 )</p><p> {</p><p> echo "This user does not exist.";</p><p> }</p><p> else</p><p> {</p><p> $userA = @mysql_fetch_array( $userQ );</p><p> if ( $userA["password"] !== md5( $password ) )</p><p> {</p><p> echo "The password you entered is incorrect.";</p><p> }</p><p> else</p><p> {</p><p> if ( $new !== $confirm )</p><p> {</p><p> echo "The two new passwords you entered do not match.";</p><p> }</p><p> else</p><p> {</p><p> $change = @mysql_query( "UPDATE `users` SET `password` = '" . $new . "' WHERE `username` = '" . $username . "'" );</p><p> if ( $change )</p><p> {</p><p> echo "Your password has been changed.";</p><p> }</p><p> else</p><p> {</p><p> echo "An error occurred with the MySQL:<br /><br />" . mysql_errno() . ": " . mysql_error();</p><p> }</p><p> }</p><p> }</p><p> }</p><p>}</p><p>else</p><p>{</p><p> echo "Change Password<br /><br /></p><p> <form method=\"post\"></p><p> Username: <input type=\"text\" name=\"username\" id=\"username\" /><br /></p><p> Current Password: <input type=\"password\" name=\"password\" id=\"password\" /><br /></p><p> New Password: <input type=\"password\" name=\"newpassword\" id=\"newpassword\" /><br /></p><p> Confirm New Password: <input type=\"password\" name=\"confirmnewpassword\" id=\"confirmnewpassword\" /><br /><br /></p><p> <input type=\"submit\" name=\"changepassword\" id=\"changepassword\" value=\"Save &raquo;\" /></p><p> </form>";</p><p>}</p><p>?>[/PHP]</p></blockquote><p></p>
[QUOTE="Markshall, post: 77740, member: 1872"] Now I'm not sure if this is what you asked for, but I've tidied up your code and make it look a little bit more presentable. [PHP]<?php session_start(); $connection=mysql_connect("localhost","root","[PASSWORD]"); $db=mysql_select_db("uber",$connection); function c( $str ) { return addslashes( @mysql_real_escape_string( $s, $connection ) ); } if ( isset( $_POST["changepassword"] ) ) { $username = c( $_POST["username"] ); $password = c( $_POST["password"] ); $new = md5( c( $_POST["newpassword"] ) ); $confirm = md5( c( $_POST["confirmnewpassword"] ) ); $userQ = @mysql_query( "SELECT * FROM `users` WHERE `username` = '" . $username . "'" ); if ( @mysql_num_rows( $userQ ) == 0 ) { echo "This user does not exist."; } else { $userA = @mysql_fetch_array( $userQ ); if ( $userA["password"] !== md5( $password ) ) { echo "The password you entered is incorrect."; } else { if ( $new !== $confirm ) { echo "The two new passwords you entered do not match."; } else { $change = @mysql_query( "UPDATE `users` SET `password` = '" . $new . "' WHERE `username` = '" . $username . "'" ); if ( $change ) { echo "Your password has been changed."; } else { echo "An error occurred with the MySQL:<br /><br />" . mysql_errno() . ": " . mysql_error(); } } } } } else { echo "Change Password<br /><br /> <form method=\"post\"> Username: <input type=\"text\" name=\"username\" id=\"username\" /><br /> Current Password: <input type=\"password\" name=\"password\" id=\"password\" /><br /> New Password: <input type=\"password\" name=\"newpassword\" id=\"newpassword\" /><br /> Confirm New Password: <input type=\"password\" name=\"confirmnewpassword\" id=\"confirmnewpassword\" /><br /><br /> <input type=\"submit\" name=\"changepassword\" id=\"changepassword\" value=\"Save »\" /> </form>"; } ?>[/PHP] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Password
Top