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 = "easycms5@easycmsnow.com";

$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
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.

Link to comment
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.