Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/181560-die/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/181560-die/#findComment-957687
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/181560-die/#findComment-957693
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.