newbiestarter Posted October 2, 2014 Share Posted October 2, 2014 Hello. I'm new to this community and I have just recently started learning PHP. I have run into the problem that the require statement doesn't seem to work: HTML 1:phplesson23.tmpl.php <!doctype html><html><head><style>li { list-style: none;}</style></head><body><h1>Join me in my journey to conquer the world!</h1><form action="" method="post"><?php if ( isset($status) ) echo $status; ?><ul><li><label for="name">Your name:</label><input type="text" name="name"></li><li><label for="email">Your email:</label><input type="text" name="email"></li><li><input type="submit" name="SIGN UP"></li></ul></form></body></html> HTML 2: phplesson23.php This is the one with the require statement. <?php if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {$name = trim($_POST['name']);$email = trim($_POST['email']); if ( empty($name) || empty($email) ) {$status = 'Provide a name and valid email.'}} require 'phplesson23.tmpl.php';?> What am I doing wrong? Link to comment Share on other sites More sharing options...
niche Posted October 2, 2014 Share Posted October 2, 2014 What happens when you delete the ref to ".tmpl"? Or, in a separate script run just the require statement? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 2, 2014 Share Posted October 2, 2014 Require statements work just fine in PHP. The real question is what are you expecting to happen when you run that code, and what actually happens? Link to comment Share on other sites More sharing options...
newbiestarter Posted October 3, 2014 Author Share Posted October 3, 2014 Thank you for the replies and I solved it. I tried running the require statement in a separate script and it worked fine so I looked over it for the 6th time and I realised there was no ';' at the end of 'Provide a name and valid email.' I can't believe I missed it when it was such a simple problem. I checked this thing so many times yesturday. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 3, 2014 Share Posted October 3, 2014 If you didn't see an error message for that, it sounds like PHP is either ignoring errors or sending everything to an error log. If this is on your computer, those settings are in php.ini. For development, you'll probably want to set display_errors to on and error_reporting to E_ALL. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now