merylvingien Posted November 15, 2009 Share Posted November 15, 2009 If i use "die" on my php pages for some reason the footer doesnt display! I take it that if die is used then no more code is executed? I can get my head around that, but is there a way to display the footer as well as it just looks better if it is displayed. For some reason if i use "echo" then the rest of the code is executed and stuff happens that i dont want to happen. Quote Link to comment https://forums.phpfreaks.com/topic/181560-die/ Share on other sites More sharing options...
trq Posted November 15, 2009 Share Posted November 15, 2009 For some reason if i use "echo" then the rest of the code is executed and stuff happens that i dont want to happen. Then you need to put your code into if statements that execute code conditionally. This really is the basics of programming logic. die as the name implies, kills execution. Quote Link to comment https://forums.phpfreaks.com/topic/181560-die/#findComment-957687 Share on other sites More sharing options...
merylvingien Posted November 15, 2009 Author Share Posted November 15, 2009 For some reason if i use "echo" then the rest of the code is executed and stuff happens that i dont want to happen. Then you need to put your code into if statements that execute code conditionally. This really is the basics of programming logic. die as the name implies, kills execution. I take it you mean like this? if (!ctype_alnum($password)){ die('<p>Your password must only contain letters and numbers(a-z) (1-9)</p>');} else if (count ($_POST['signupID']) > 6){ die ('<p>You have been naughty and tried to cheat, but we have caught you out! Now don\'t be silly!</p>');} else if (empty ($fname)) {die ('<p>There appears to be a problem, please go back and try again</p>');} else if (empty ($email)) {die ('<p>There appears to be a problem, please go back and try again</p>');} else if (empty ($phone)) {die ('<p>There appears to be a problem, please go back and try again</p>');} else if (empty ($advert)) {die ('<p>There appears to be a problem, please go back and try again</p>');} else if (strlen($fname) < 3) {die ('<p>The amount of letters for your display name is too short, please go back and correct this.</p>');} else if (strlen($fname) >50) {die ('<p>The amount of letters for your display name is too long, please go back and correct this.</p>');} else if (strlen($advert) < 100) {die ('<p>The amount of words in your advert is too short, please go back and add more content.</p>');} else if (strlen($advert) > 1000){die ('<p>For some reason your advert text is too long, please go back and reduce the amount of characters to below 1000</p>');} else if (strlen($phone) < {die ('<p>There appears to be a problem with your telephone number, please go back and check that it is correct</p>');} else if (strlen($phone) > 16) {die ('<p>There appears to be an error with your phone number, please go back and check that it is correct.</p>');} else if (strlen($mobile) > 16) {die ('<p>There seems to be an error with your mobile number, please go back and check that it is correct.</p>');} else if (strlen($password) < 6) {die ('<p>The Password you have entered is less than 6 characters, to make sure your password is strong please go back and select another password between 6 and 16 long.</p>');} else if (strlen($password) > 16) {die ('<p>The password you have entered is more than 16 characters, a password this long is not needed to be secure, your password will be encrypted with a 128 bit hash, which is virtually impossible to crack. Please go back and select a password between 6 and 16 characters long.</p>');} else etc Like i said, if i use echo it just runs through the rest of the code and appears to ignore the if statments. Quote Link to comment https://forums.phpfreaks.com/topic/181560-die/#findComment-957693 Share on other sites More sharing options...
merylvingien Posted November 15, 2009 Author Share Posted November 15, 2009 Hmm i think i can see more errors in my code, excuse this post! Quote Link to comment https://forums.phpfreaks.com/topic/181560-die/#findComment-957698 Share on other sites More sharing options...
oni-kun Posted November 15, 2009 Share Posted November 15, 2009 You need to either add the footer insertion into the DIE code (lazy) or create your own custom function to stop execution. Really, you should not use die() unless it is an error. A 'try' loop may work more in your favour. Quote Link to comment https://forums.phpfreaks.com/topic/181560-die/#findComment-957715 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.