Results 1 to 7 of 7

Thread: Mysteriously Vanishing Footer

  1. #1
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default Mysteriously Vanishing Footer

    This code excerpt causes my footer to show up only when there is an error. I think it has something to do with "exit." Anyone know how to make the footer show all the time? Thanks! erin

    Code:
    if ($myrow[cal_email] == ""){
      $error = "<p>NO RECORD WAS FOUND.</p>"; 
      if ($error != ""){ echo "<font color=990000>$error</font>"; } 
      } else {
      mail("$email", "Your Login Info ", "Blah blah");
      print "<p>YOUR PASSWORD WAS MAILED.</p>";
      exit;	}
      } 
      ?>
    </div>
    <div id="footer"><? include('footer.php'); ?></div>
    Last edited by kuau; 05-18-2008 at 08:58 PM. Reason: forgot code tags

  2. #2
    Join Date
    May 2008
    Posts
    1
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    HI Erin,

    I don't think you need an 'exit' there, I've never used that (when I want to get out of a conditional or a loop... I've used 'break' before).

    I noticed theres an extra }, is that for some code above that?

    This is how I'd handle that part:

    PHP Code:
    <?php

    if ($myrow[cal_email] == "")
        {
        
    $error "<p>NO RECORD WAS FOUND.</p>";
        echo 
    "<font color=990000>$error</font>";
        }
    else
        {
        
    mail("$email""Your Login Info ""Blah blah");
        echo 
    "<p>YOUR PASSWORD WAS MAILED.</p>";
        }
     
    ?>

    </div>

    <div id="footer"><? include('footer.php'); ?></div>
    I removed the if($error!="") because it was in a section which had just set error to something - so it would always be true in that code (to avoid that - you need a '}'after the $error= statement). I consolidated that and it should work fine.

    Mainly though, the problem with what you asked about was 'exit'. That stops the whole script! It only ran when there was no error, since the other branch (error) skipped the part with 'exit'. Don't 'exit'!

    Hope that helps.
    -Jerry

  3. The Following User Says Thank You to jerry_linseed For This Useful Post:

    kuau (05-16-2008)

  4. #3
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Dear Jerry: Thank you! Did I mess it up? because it still doesn't show. Here's more of the code. It is driving me nuts:

    Code:
    <form action=/php/password.php method=post>
    		<input type=hidden name=action value=doit>
    		<b>Email:</b> <input type=text name=email size=35>
    		<input type=submit value=SEARCH>    
    		</form>
        <?
    		if ($action == "doit")
    		{   
    			require "mysql_options.php";
    			require "my_functions.php";
    			$mydatabase = new MySQL_options;
    			$mydatabase->init();			
    			$sql = "SELECT * FROM webcal_user WHERE cal_email='$email' ";
    			$data = $mydatabase->select($sql);
    			$num = count(data);
    			$myrow = $data[0];
    			if ($myrow[cal_email] == "")
    			  {
    				$error = "<p>NO RECORD WAS FOUND IN THE DATABASE FOR:</p><p><b>$email</b></p><p>Please try again.</p>"; 
    				echo "<font color=990000>$error</font>";  
    		    } else {
    			  mail("$email", "Your Calendar Maui Login Info ", "Aloha $myrow[cal_firstname],\n\n Your username is: $myrow[cal_login] \n\n Your password is: $myrow[cal_passwd] \n\n Please go to http://www.calendarmaui.com/ to log in. ", "From: Calendar Maui<info@calendarmaui.com>\r\n");
    			  echo "<p>YOUR USERNAME AND PASSWORD WERE MAILED TO:</p><p><b>$email</b></p><p>Please check your email.</p>";
    			}} ?>
      </div>
    <div id="footer"><? include_once('footer.php'); ?></div>
    Last edited by kuau; 05-18-2008 at 08:57 PM. Reason: forgot code tags

  5. #4
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    if you are using a variable in the middle of a string do this:
    Code:
    "bla bla bla" . $variable . "rest of string";
    That is all I saw but otherwise it looks ok...

  6. #5
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Thanks, Rockon: It's working!! Thanks a million. erin PS. is the \n\n part of the string or the php?
    Last edited by kuau; 05-17-2008 at 01:22 AM. Reason: correction

  7. #6
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    Um... err... I don't know... I just use <br /> tags. I don't think so... Uh One other thing... Next time please, pretty please? use the code boxes... They are really helpful and make it easier on our eyes... Thanks!
    I'm glad I could help!

  8. #7
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Dear Rockon: I went back and put the code tags just for you. Thanks for your help!

    erin

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •