# PHP pop up for thanks

**URL:** <https://forum.kirupa.com/t/php-pop-up-for-thanks/83356>\
**Category:** programming\
**Created:** [March 18, 2005, 2:20am UTC](https://forum.kirupa.com/t/php-pop-up-for-thanks/83356 "2005-03-18T02:20:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dude9er](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dude9er](https://forum.kirupa.com/u/dude9er)\
**Post date:** [March 18, 2005, 2:20am UTC](https://forum.kirupa.com/t/php-pop-up-for-thanks/83356/1 "2005-03-18T02:20:46Z")

</div>

I’m doing a form using PHP coding. I’d like to know if this is possible.

I’d like a Microsoft pop to show a “thank you” message or “error” message when the form is submitted rather than forwarding to a thankyou or error page. Is this possible using PHP.

steps:

1. Fill in email
2. submit button pressed
3. if email is invalid, an error message pops up
4. if email is valid, a thank you message pops up
5. email is sent
6. auto response is sent to email address

Here’s my code:

```php
<?

//Declare the variables
$siteaddress ="http://www.webaddress.com"; 
$sitename = "eslbuzzCANADA"; 
$adminaddress = "newsletter@webaddress.com";
$subject = "SIGN UP";

//Gets date and time from server
$date = date("m/d/Y H:i:s");

// Gets the IP Address
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);

//Contents of form

//////////////////////////////////////////////////////////////////

//HERE IS THE VALIDATION, WHAT DO I CHANGE TO CREATE THE POP UPS?

 $email = $_REQUEST['email'] ;

  if (!isset($_REQUEST['email'])) {
    header( "Location: http://www.webaddress.com/thankyou.htm" );
  }
  elseif (empty($email)) {
    header( "Location: http://www.webaddress.com/error.htm" );
}
  elseif (!strpos($email,"@")>0) {
    header( "Location: http://www.webaddress.com/error.htm" ); 
  }
  else {
    
    header( "Location: http://www.webaddress.com/thankyou.htm" );	

/////////////////////////////////////////////////////////////////////
//mail() function sends the mail

	mail ("$adminaddress","Info Request",
	"A visitor at $sitename has left the following information
 
	Email: $email

	The visitor has subscribed to the NEWSLETTER.
	------------------------------

	
	Logged Info :
	------------------------------
	Using: $HTTP_USER_AGENT
	Hostname: $ip
	IP address: $REMOTE_ADDR
	Date/Time: $date","FROM:$adminaddress" ) ; 

//This sends a confirmation to your visitor
mail ("$email","Thank You for visiting $sitename", 
	"Hi $email,

	Thank you for your interest in $sitename!
 
	You have just subscribed to the webaddress.com newsletter.

	Thanks again!!

	$sitename
	CHANGING THE WORLD ONE TEACHER AT A TIME!

	$siteaddress
	$adminaddress", "FROM:$adminaddress") ; 

}
//This line sends to thankyou page when finished

?>

```

and here is the code in my html

```php

<form action="form.php" method=POST >
            <p>
              <input type=text name=email>
            </p>
            <p>
              <input name="submit" type="submit" id="submit" value="Submit">
            </p>
          </form>

```

Thank you in advance for any help.
