Jump to content
Killersites Forums

How to add footer to php error message


Recommended Posts

I have a php code that does not show the footer unless the message is correct and gets sent. If there is an error in filling in the fields the code does not show the footer. I know I have to put an 'else' statement in there, but I have no idea how. If there is any bad code in there please feel free to correct it, I am a PHP idiot.... :rolleyes:

 

    



$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$phone = $_POST['phone'];


if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "Please hit the Back buttonPlease Enter a valid e-mail address\n";
$badinput = "Your email was NOT sent\n";
echo $badinput;
die ("
Use browser back button !");
}

if(empty($visitor) || empty($visitormail) || empty($phone) || empty($notes )) {
echo "Please hit the Back button - fill in all fields\n";
die ("
Use browser back button !");
}

THIS IS WHERE I NEED THE STATEMENT TO MAKE IT GO TO THE END AND THEN READ THE FOOTER

$todayis = date("l, F j, Y, g:i a") ;

$phone = $phone;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Message: $notes \n
From: $visitor ($visitormail)\n
Referral : tenerifebusinessinformation \n
";

$from = "From: $visitormail\r\n";


mail("lynne.mb@gmail.com", $subject, $message, $from);

?>




Thank you  for expressing your interest in Tenerife Business Information. We look forward to speaking with you and helping you get started on your new or existing project. Below is the information you entered on our form, we will contact you soon. Once again Thank You and we look forward to working with you.




Phone Number: 


Message:

", $notes);
echo $notesout; ?>


Return to Home Page


Edited by virtual
Link to post
Share on other sites

Just to be sure, so I have to put the closing content div, message div and then the footer div in each of the error messages before the "die"? Then also leave it at the end so that when the script reads correctly it will close the divs and add the footer?

 

Ben I just got the 180 second wait thing again...

Link to post
Share on other sites

I'll need to look at this in a bit more detail later today...

 

Where exactly is the code that contains your footer? Is it in the code you provided in the first post? (If I understand it correctly, the code you're showing in your first post only includes the content div, not anything else?) Are you including the code you showed in your first post within an include? for example

 

Main file:

-- include header

-- include content (code in your first post)

-- include footer

 

If so, using die() may prevent the footer div from being included, so it's possible using die() isn't a good choice here and it should be removed.

Link to post
Share on other sites

No I'm not yet using includes as I am still building out the site. It actually doesn't matter too much if it doesn't show the footer on the error message but it is not closing out the message and content div either which is more important as the design looks incomplete.

 

That's why I thought an "if else" would be better, but as I said I have taken 3 classes in PHP and never finished any of them, I'm a complete right brainer....

Link to post
Share on other sites
Where exactly is the code that contains your footer? Is it in the code you provided in the first post? If so, can you let me know which parts of that code display your footer? (If I understand it correctly, the code you're showing in your first post only includes the content div, not anything else?)

 

Just repeating the question...

Link to post
Share on other sites

If you aren't worried about the footer anymore, try something like this:

 

replace the two

 

die ("

Use browser back button !

");

 

with two

 

die ("

Use browser back button !

");

 

(or however many closing divs is appropriate.) I haven't tested this obviously, but try this and let me know if that fixes things for you.

 

The die() function prints out whatever is in the parenthesis, and then the script is completely terminated -- no more code, php or otherwise, will execute/display after the die() statement.

Link to post
Share on other sites

Hey Eric, don't get your knickers in a twist. :/

 

If you read my posts you would understand that I don't know what the heck I'm doing when it comes to PHP, so I can't even begin to hack away at the premade script because I barely understand it. I drop it in and hope for the best. As I said previously feel free to change or correct whatever, but please explain it like you were talking to a 2 year old.... well maybe a little older than that!

Link to post
Share on other sites

Thanks Ben, I did see the post but I am 8 hours ahead of you so it was too late for me to try it out.

 

replace the two

 

die ("

Use browser back button !

");

 

with two

 

die ("

Use browser back button !

");

 

Tried that and it doesn't close out the two divs.

 

I also tried this and it didn't work either - this is why I hate PHP, I just don't get it... :(

 

echo "

Please hit the Back button

Please Enter a valid e-mail address

\n";

$badinput = "

Your email was NOT sent

Use browser back button

\n";

$closedivs = "

Edited by virtual
Link to post
Share on other sites

Hope this helps. I tried the idea suggested by Falcencreative and it works perfectly.

 

All " in the code should be replaced with ' and includes dont seem to work so you will have to write the full code. the following code was entered in every die which is a pain on a large verified form but it does work. You didnt include you footer code so I cant advise further, maybe if you publish it falcencreative will post the correct code.

 

{

die(" You haven't Entered Your First Name. Go back and Enter your First Name


footer
". mysql_error());

}

Link to post
Share on other sites

What I posted should work fine... And your method should have also worked. I'm guessing there may be something else going on here that's affecting things. Can you post your entire code -- both the page that displays the contact form, and also the entire page that processes the form -- either here or send it to me via IM or my email (ben [at] falkencreative.com). That way I can test it on my local machine.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...