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:
- Fill in email
 - submit button pressed
 - if email is invalid, an error message pops up
 - if email is valid, a thank you message pops up
 - email is sent
 - auto response is sent to email address
 
Here’s my code:
<?
//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
<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.