<?php include('core/init.inc.php'); if (isset($_POST['username'], $_POST['password'], $_POST['repeat_password'])){ if (empty($_POST['username'])){ $error[] = 'The username cannot be empty.'; } if (empty($_POST['password']) || empty($_POST['repeat_password'])){ $errors[] = 'The password cannot be empty.'; } if ($_POST['password'] !== $_POST['repeat_password']){ $errors[] = 'Password verification failed.': } if(user_exists($_POST['username'])){ $errors[] = 'The username you entered is already taken.'; } if (empty($errors)){ add_user($_POST['username'], $_POST['password']); $_SESSION['username'] = htmlentities($_POST['username'])); header('Location: protected.php'); die(); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>HELLO</title> </head> <body><p> <?php ?> </p> <form action="" method="post"><p> <label for="username">Username:</label> <input type="text" name="username" id="username" /></p> <p> <label for="password">Password:</label> <input type="password" name="password" id="password" /></p> <p> <lablefor="repeat_password">Repeat Password:</label> <input type="password" name="repeat_password" id="repeat_password" /></p> <p> <input type="submit" value="Register" /> </p> </form> </body> </html>
Code will not allow html to show.
-
- Posts: 5
- Joined: Mon Jun 06, 2011 3:55 pm
Code will not allow html to show.
I followed a tutorial on youtube from betterphp about using MySQL and PHP to create a login and register system for a web site. I followed as the tutorial showed, up to part 3. The problem is when i have the php/sql code in the file, it wont let the html code show up on the screen. So all i get is a blank page. But when i remove the php code the html code shows up and i see what i want to. Below is my script used:
Re: Code will not allow html to show.
In line 15 you have a : instead of ;
and in line 25 is a ) to much...
and in line 25 is a ) to much...
Re: Code will not allow html to show.
That suggests you made a syntax error somewhere and do not have php set up to tell you about it, so it just dies. If you have access to the php.ini file you can set error_reporting = E_ALL and display_errors = On for more info ... http://www.youtube.com/watch?v=4OH0b-x96ZoDonVito186 wrote: So all i get is a blank page
-
- Posts: 5
- Joined: Mon Jun 06, 2011 3:55 pm
Re: Code will not allow html to show.
I fixed the miss-spelling that element pointed out. I also edited the ini file to display errors, and it doesnt say anything. I still get a blank screen.
-
- Posts: 5
- Joined: Mon Jun 06, 2011 3:55 pm
Re: Code will not allow html to show.
I am not using Apache, but rather IIS7. And yes i did restart it and still nothing.
Re: Code will not allow html to show.
Can you post the full code as it is now ?
Also does your php set up work ? you could try a test file like
Sorry for the patronising questions, I have to ask
Also does your php set up work ? you could try a test file like
<?php echo 'test'; ?>to check this.
Sorry for the patronising questions, I have to ask
-
- Posts: 5
- Joined: Mon Jun 06, 2011 3:55 pm
Re: Code will not allow html to show.
My PHP works, i've been working on other pages for my website other than the login/register. Below is the code as is now.
<?php include('core/init.inc.php'); if (isset($_POST['username'], $_POST['password'], $_POST['repeat_password'])){ if (empty($_POST['username'])){ $error[] = 'The username cannot be empty.'; } if (empty($_POST['password']) || empty($_POST['repeat_password'])){ $errors[] = 'The password cannot be empty.'; } if ($_POST['password'] !== $_POST['repeat_password']){ $errors[] = 'Password verification failed.'; } if(user_exists($_POST['username'])){ $errors[] = 'The username you entered is already taken.'; } if (empty($errors)){ add_user($_POST['username'], $_POST['password']); $_SESSION['username'] = htmlentities($_POST['username'])); header('Location: protected.php'); die(); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>HELLO</title> </head> <body><p> <?php ?> </p> <form action="" method="post"><p> <label for="username">Username:</label> <input type="text" name="username" id="username" /></p> <p> <label for="password">Password:</label> <input type="password" name="password" id="password" /></p> <p> <lablefor="repeat_password">Repeat Password:</label> <input type="password" name="repeat_password" id="repeat_password" /></p> <p> <input type="submit" value="Register" /> </p> </form> </body> </html>
Re: Code will not allow html to show.
Line 25. Syntax error
remove 1 )
remove 1 )
$_SESSION['username'] = htmlentities($_POST['username']);
-
- Posts: 5
- Joined: Mon Jun 06, 2011 3:55 pm
Re: Code will not allow html to show.
That line was in the tutorial and it worked for him, but now its working for me. Thank you so very much!element wrote:Line 25. Syntax error
remove 1 )
$_SESSION['username'] = htmlentities($_POST['username']);
Re: Code will not allow html to show.
I had it with one )DonVito186 wrote:That line was in the tutorial and it worked for him, but now its working for me. Thank you so very much!
Also php should have told you about this error Something is stopping your errors from being displayed. You will find it very hard to debug / develop with hidden errors.