dudejma Posted June 21, 2011 Share Posted June 21, 2011 I was wondering how to show errors within my template. For example, <?php $x = $_REQUEST['x']; $y = $_REQUEST['y']; if ($x == $y) { // Execute code if it works } else ($x != $y) { // Error would be: X did not equal Y. Please correct. } ?> My question is, how, instead of echoing the error onto a new, blank page, to echo it onto my template. Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/239955-showing-errors/ Share on other sites More sharing options...
Pikachu2000 Posted June 21, 2011 Share Posted June 21, 2011 It isn't clear where you're having problems. Is there a particular reason you can't just echo the errors where you need them echoed? Quote Link to comment https://forums.phpfreaks.com/topic/239955-showing-errors/#findComment-1232623 Share on other sites More sharing options...
dudejma Posted June 21, 2011 Author Share Posted June 21, 2011 I'm very new to PHP but what I'm trying to say is.. Well. Okay, you know how when you echo something, it echos onto a blank white page. Well, I have a template, and I'm wanting the error to echo onto that template. Where would I echo my template and where would I place the error's echo? Quote Link to comment https://forums.phpfreaks.com/topic/239955-showing-errors/#findComment-1232624 Share on other sites More sharing options...
Pikachu2000 Posted June 21, 2011 Share Posted June 21, 2011 It will echo wherever you code it to echo. I think your best bet is going to be to post your code. When you say template, are you referring to a form, by chance? Quote Link to comment https://forums.phpfreaks.com/topic/239955-showing-errors/#findComment-1232628 Share on other sites More sharing options...
dudejma Posted June 21, 2011 Author Share Posted June 21, 2011 Well, for instance. I'm wanting people to fill out a form. And I want, if they left a field blank, for it to say: Blah blah blah. My question is, how would I get it to say Blah blah blah on my template instead of echoing it onto a completely white page.. In other words, WHERE would I echo it to make it onto my template. Ex. <?php $x = $_REQUEST['x']; $y = $_REQUEST['y']; if (empty($x)) { echo "X value was left blank. Please check entry."; } ?> I want to know, how can I incorporate my template into this and have the echo inside my template. Quote Link to comment https://forums.phpfreaks.com/topic/239955-showing-errors/#findComment-1232629 Share on other sites More sharing options...
Pikachu2000 Posted June 21, 2011 Share Posted June 21, 2011 Have a read through THIS POST. I pasted in some example code there that should at least give you the basics. Copy it in to a new script, execute it and see how it works. Quote Link to comment https://forums.phpfreaks.com/topic/239955-showing-errors/#findComment-1232630 Share on other sites More sharing options...
dudejma Posted June 21, 2011 Author Share Posted June 21, 2011 Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/239955-showing-errors/#findComment-1232632 Share on other sites More sharing options...
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.