Jump to content

php display text inside of the body


goodealsnow

Recommended Posts

This is a real example.

www.easycmsnow.com/crest/contact.htm

 

To see my problem fill out the form except for the email. Hit submit.

You should be redirected to the same page but at the bottom of the page it will say

"Please check your email address it was not formatted correctly"

 

How do I display this directly below my contact form.

 

Here is my script.

<?php

 

// Receiving variables

@$pfw_ip= $_SERVER['REMOTE_ADDR'];

@$name = addslashes($_POST['name']);

@$email = addslashes($_POST['email']);

@$message = addslashes($_POST['message']);

 

// Validation

if (strlen($name) <1)

{

include('contact.htm');

printf("The name is to short.");

}

if (strlen($name) >100)

{

include('contact.htm');

printf("<p>The name is to long</p>");

}

 

if (strlen($name) == 0 )

{

include('contact.htm');

printf("<p>You forgot to input your name. Make sure all fiedls are filled up with your information. </p>");

 

}

 

if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))

{

include('contact.htm');

printf(" <p> Please check your email address it was not formatted correctly</p>");

exit;

}

 

//Sending Email to form owner

$pfw_header = "From: $email\n"

  . "Reply-To: $email\n";

$pfw_subject = "CEA-CREST contact form";

$pfw_email_to = "[email protected]";

$pfw_message = "Visitor's IP: $pfw_ip\n"

. "name: $name\n"

. "email: $email\n"

. "message: $message\n";

@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

 

include 'thankyou.html';

 

?>

 

Link to comment
https://forums.phpfreaks.com/topic/90980-php-display-text-inside-of-the-body/
Share on other sites

The way I usually handle forms, is to have them submit to themselves.  Include all of the processing and validation of your form above the form only if the form has been submitted.  If there are any errors, show the form again and list the errors.  If there were no errors, hide the form, send the e-mail and display a confirmation message.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.