# Php email form

**URL:** <https://forum.kirupa.com/t/php-email-form/236009>\
**Category:** Uncategorized\
**Created:** [August 16, 2007, 1:51pm UTC](https://forum.kirupa.com/t/php-email-form/236009 "2007-08-16T13:51:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![killahert](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@killahert](https://forum.kirupa.com/u/killahert)\
**Post date:** [August 16, 2007, 1:51pm UTC](https://forum.kirupa.com/t/php-email-form/236009/1 "2007-08-16T13:51:28Z")

</div>

I searched every thread on these formus but didn’t find any info that I need.

I have a php form and I need to be able after submitting to display success text in the same window is it possible?

```php

<?php
if(isset($_POST['submit'])) {

$to = "blah@blah.com";
$subject = "web form";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
 
$body = "From: $name_field
 E-Mail: $email_field
 Message:
 $message";
if (!eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['email'])))) 
{
     echo 'error!! try again';
     exit;
}  

$headers = "From: $email";
mail($to, $subject, $message, $headers);   
echo "message sent: $to!";
mail($to, $subject, $body);

} else {

echo "wrong email address, check the email and try again!";

}
?>

```

so for errors and success I’d like to be able to display information in the same page without opening a new window. of ocourse if this can be done
