Blade Maker Posted November 4, 2009 Posted November 4, 2009 I watched the php academy videos and I watched the one where you make a register script. Here is the code I made while watching it: <php echo "<h1>Register</h1>"; $submit = strip_tags($_POST['submit']); $firstname = strip_tags($_POST['firstname']); $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password'])); $repeatpassword = strip_tags($_POST['repeatpassword'])); $date = date("Y-m-d"); if ($submit) { if ($firstname&&$username&&$password&&$repeatpassword) { $password = md5($password); $repeat = md5($repeatpassword); if ($password==$repeatpassword); { if (strlen($firstname)>25||strlen($username)>25) { echo "Max character length for first name or username is 25."; } else { if (strlen($password)>25||strlen(password)<6) { echo "Password is only allowed 6-25 characters long."; } { .... } } else echo "Your passwords do not match."; } else echo "Please fill in all fields."; } ?> <html> <form action='register.php' method='POST'> <table> <tr> <td> Your first name: </td> <td> <input type='text' name='register'> </td> </tr> <tr> <td> Choose a username: </td> <td> <input type='text' name='username'> </td> </tr> <tr> <td> Choose a password: </td> <td> <input type='password' name='password'> </td> </tr> <tr> <td> Repeat your password: </td> <td> <input type='password' name='repeatpassword'> </td> </tr> </table> <input type='submit' name='submit value='register'> </form> </html> What is the problem with this code, here is the link to the video thanks. http://www.youtube.com/user/phpacademy#p/s...h/0/IUCEEh-ASH8 this is only the 3rd tutorial on this, but this is where I got stuck. Quote
a_bertrand Posted November 4, 2009 Posted November 4, 2009 around line 34 you have this: { .... } Well sorry but that will simply not work. Also your { counts doesn't seems to match the } and finally... your script does nothing beside checking for all kind of problems. I mean, it will never create an account unless you write the account information on a database or something similar. Quote
Blade Maker Posted November 4, 2009 Author Posted November 4, 2009 OK in the video I am suppose to move on this script is not done. ...... is what I just put in until the next video. Now I noticed the <php did not have the ? so I put that in now the code is not showing. So what do I need to fix, I believe I did what the video says. Quote
Zero-Affect Posted November 4, 2009 Posted November 4, 2009 i really don't understand that script you posted, closing the ?> before the end of the file is never a good idea i would refer to a alternative video if they are telling you to do that. Quote
Haunted Dawg Posted November 4, 2009 Posted November 4, 2009 i really don't understand that script you posted, closing the ?> before the end of the file is never a good idea i would refer to a alternative video if they are telling you to do that. Explain how it can never be a good idea? He is closing of PHP and resulting to HTML at the end? Quote
Blade Maker Posted November 5, 2009 Author Posted November 5, 2009 Thanks guys but I already fixed it. I used the w3schools forum. Quote
a_bertrand Posted November 5, 2009 Posted November 5, 2009 Zerro: You can open and close the PHP tags as many times as you want inside your files and whatever is outside the tags will simply be printed out like inside an echo, so it's certainly not a bad idea to close the tag to just have some static HTML. Quote
Zero-Affect Posted November 5, 2009 Posted November 5, 2009 Maybe in new php it isn't a issue but i seem to remember being told by a actual programmer that it was a issue which is why i never did it, something to do with whitespace i believe but im sure the administration knows best, my mistake. Quote
Haunted Dawg Posted November 5, 2009 Posted November 5, 2009 Maybe in new php it isn't a issue but i seem to remember being told by a actual programmer that it was a issue which is why i never did it, something to do with whitespace i believe but im sure the administration knows best, my mistake.It can only slow down the page, nothing more. Quote
Zero-Affect Posted November 5, 2009 Posted November 5, 2009 ah yes i did just do a little research most of the results said ?> is not needed... it's issued to prevent injections and trailing whitespaces, i still say it should only be at the end of the file but maybe im wrong. Quote
Toppy Posted November 5, 2009 Posted November 5, 2009 Somehow we got off topic but... The latest trend is to omit the closing php code '?>' at the end of the file if in PHP code. This prevents problems of whitespaces or extra characters at the end of the file which could cause errors or what-have-you. Again, that is at the end of PHP code when at the end of a file. There is nothing wrong with closing PHP and including HTML at the end (beginning or middle even). That is one of the strengths of PHP and why it became so popular. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.