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
Software Development
Programming
[NOOB] Newbie Registration (PHP) [NOOB]
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="Khalil" data-source="post: 228916" data-attributes="member: 9938"><p>This...this is just so wrong in many ways!</p><p></p><p>First of all, you forgot the semicolons in your mysql configuration.</p><p>[PHP]$db_name="user";// Database name</p><p>$tbl_name="user";// Table name[/PHP]</p><p></p><p>Your mysql connection script is pretty fucked, so heres the fix:</p><p></p><p>[PHP]mysql_connect($host, $username, $password)or die("cannot connect");</p><p>mysql_select_db($db_name)or die("cannot select DB");[/PHP]</p><p></p><p>Your login page is fucked:</p><p></p><p>[HTML]</p><p><table> width="300" border="0"</p><p>align="center" cellpadding="0"</p><p>cellspacing="1" bgcolor=#CCCCCC></p><p> <tr></p><p> <form name="form1" method="post"</p><p> action="checklogin.php"></p><p> <td></p><p> <table width="100%" border="0"</p><p> cellpaddng="3" cellspacing="1"</p><p>bgcolor="#FFFFFF"></p><p> <tr></p><p> <td> width="78">Username</td></p><p> <td>width="6">:</td></p><p> <td> width="294"><input</p><p> name="Bradley" type="text"</p><p> id="Bradley"></td></p><p> </tr></p><p> <tr></p><p> <td>Password</td></p><p> <td>:</td></p><p> <td><input name="brad123"</p><p> type="text" id=brad123</td></p><p> </tr></p><p> <td>&nbsp;</td></p><p> <td>&nbsp;</td></p><p> <td><input type ="submit"</p><p> name="Submit" value="Login"></td></p><p> </tr></p><p> </table></p><p> </td></p><p> </form></p><p> </tr></p><p></table></p><p></p><p>[/HTML]</p><p></p><p>Fix:</p><p></p><p>[HTML]</p><p><table width="300" border="0"</p><p>align="center" cellpadding="0"</p><p>cellspacing="1" bgcolor=#CCCCCC></p><p> <tr></p><p> <form name="form1" method="post"</p><p> action="checklogin.php"></p><p> <td></p><p> <table width="100%" border="0"</p><p> cellpaddng="3" cellspacing="1"</p><p>bgcolor="#FFFFFF"></p><p> <tr></p><p> <td width="78">Username</td></p><p> <td width="6">:</td></p><p> <td width="294"><input</p><p> name="Bradley" type="text"</p><p> id="Bradley"></td></p><p> </tr></p><p> <tr></p><p> <td>Password</td></p><p> <td>:</td></p><p> <td><input name="brad123"</p><p> type="text" id=brad123</td></p><p> </tr></p><p> <td>&nbsp;</td></p><p> <td>&nbsp;</td></p><p> <td><input type ="submit"</p><p> name="Submit" value="Login"></td></p><p> </tr></p><p> </table></p><p> </td></p><p> </form></p><p> </tr></p><p></table></p><p></p><p>[/HTML]</p><p></p><p>In the checklogin.php, two lines are pretty fucked up and that would ruin the rest of the script, there are the lines and under them is the fix:</p><p></p><p>Fucked up line:</p><p>[PHP]</p><p>$myusername="_POST['myusername']</p><p>[/PHP]</p><p></p><p>Fix:</p><p>[PHP]</p><p>$myusername=$_POST['myusername'];</p><p>[/PHP]</p><p></p><p>And, the the name in the username input is "Bradley" and in the pass input is "brad123", they should be "myusername" and "mypassword" for this script to function.</p><p></p><p>Oh and this line is fucked up too:</p><p>[PHP]session_register("myusername);[/PHP]</p><p></p><p>Fix:</p><p>[PHP]session_register("myusername");[/PHP]</p><p></p><p>And next time, if you want to comment a line, don't forget the slashes in the start otheriwse it'll output that line in the page:</p><p>[PHP]// and redirect to file "login_succcess.php"[/PHP]</p><p></p><p>Oh and your login_success page, you forgot to comment the three first lines:</p><p>By the looks of it, you wanted the user of this script to read those lines but not output them in the page or show them in the code source, you could have just included them between the php tags and added the two slashes to the start of the second line.</p><p>[PHP]</p><p>//Check if session is not registered,</p><p>//redirect back to main page.</p><p>//Put this code in first line of web page. [/PHP]</p><p></p><p>P.S: Next time, secure the info with hashing or encryption.</p></blockquote><p></p>
[QUOTE="Khalil, post: 228916, member: 9938"] This...this is just so wrong in many ways! First of all, you forgot the semicolons in your mysql configuration. [PHP]$db_name="user";// Database name $tbl_name="user";// Table name[/PHP] Your mysql connection script is pretty fucked, so heres the fix: [PHP]mysql_connect($host, $username, $password)or die("cannot connect"); mysql_select_db($db_name)or die("cannot select DB");[/PHP] Your login page is fucked: [HTML] <table> width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor=#CCCCCC> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpaddng="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td> width="78">Username</td> <td>width="6">:</td> <td> width="294"><input name="Bradley" type="text" id="Bradley"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="brad123" type="text" id=brad123</td> </tr> <td> </td> <td> </td> <td><input type ="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> [/HTML] Fix: [HTML] <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor=#CCCCCC> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpaddng="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="Bradley" type="text" id="Bradley"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="brad123" type="text" id=brad123</td> </tr> <td> </td> <td> </td> <td><input type ="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> [/HTML] In the checklogin.php, two lines are pretty fucked up and that would ruin the rest of the script, there are the lines and under them is the fix: Fucked up line: [PHP] $myusername="_POST['myusername'] [/PHP] Fix: [PHP] $myusername=$_POST['myusername']; [/PHP] And, the the name in the username input is "Bradley" and in the pass input is "brad123", they should be "myusername" and "mypassword" for this script to function. Oh and this line is fucked up too: [PHP]session_register("myusername);[/PHP] Fix: [PHP]session_register("myusername");[/PHP] And next time, if you want to comment a line, don't forget the slashes in the start otheriwse it'll output that line in the page: [PHP]// and redirect to file "login_succcess.php"[/PHP] Oh and your login_success page, you forgot to comment the three first lines: By the looks of it, you wanted the user of this script to read those lines but not output them in the page or show them in the code source, you could have just included them between the php tags and added the two slashes to the start of the second line. [PHP] //Check if session is not registered, //redirect back to main page. //Put this code in first line of web page. [/PHP] P.S: Next time, secure the info with hashing or encryption. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
[NOOB] Newbie Registration (PHP) [NOOB]
Top