Jump to content

How to have a popup window show when php form is validated.


PDXDesigner

Recommended Posts

Hello,

 

First off I would like to say that I am not a programmer. I am mainly a designer, although I do know JavaScript well, except that I am using a HTML/PHP form on a website I am doing. The form works and it even redirects to the correct page. However, instead of redirecting to a new page I would like it to call a popup window (600px x 400px)but leave the page that the form is on open so when they close the popup window the page is still there.

 

If anyone can help that would be great! I have scoured Google and other forums with no help.

 

The codes to redirect after validation is below:

 

 

# Redirect user to the error page

 

if ($ValidationFailed === true) {

 

header("Location: http://www.craigperry.com/newsite/consultation_Error.htm");

exit;

 

}

 

 

 

The entire Code is below:

 

 

<?PHP

 

error_reporting(E_ERROR | E_WARNING | E_PARSE);

ini_set('track_errors', true);

 

function DoStripSlashes($FieldValue)

{

if ( get_magic_quotes_gpc() ) {

  if (is_array($FieldValue) ) {

  return array_map('DoStripSlashes', $FieldValue);

  } else {

  return stripslashes($FieldValue);

  }

} else {

  return $FieldValue;

}

}

 

#----------

# FilterCChars:

 

function FilterCChars($TheString)

{

return preg_replace('/[\x00-\x1F]/', '', $TheString);

}

 

 

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {

$ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];

} else {

$ClientIP = $_SERVER['REMOTE_ADDR'];

}

 

$FTGname = DoStripSlashes( $_REQUEST['name'] );

$FTGemail = DoStripSlashes( $_REQUEST['email'] );

$FTGphone = DoStripSlashes( $_REQUEST['mainphone'] );

$FTGphone = DoStripSlashes( $_REQUEST['alternatephone'] );

$FTGcity = DoStripSlashes( $_REQUEST['city'] );

$FTGstate = DoStripSlashes( $_REQUEST['state'] );

$FTGnotes = DoStripSlashes( $_REQUEST['notes'] );

 

 

 

# Redirect user to the error page

 

if ($ValidationFailed === true) {

 

header("Location: http://www.craigperry.com/newsite/consultation_Error.htm");

exit;

 

}

# Email to Form Owner

 

$emailSubject = FilterCChars("Free Consultation Information");

 

$emailBody = "name : $FTGname\n"

. "email : $FTGemail\n"

. "mainphone : $FTGphone\n"

. "alternatephone : $FTGphone\n"

. "city : $FTGcity\n"

. "state : $FTGstate\n"

. "notes : $FTGnotes\n"

. "";

$emailTo = 'Steve <[email protected]>';

 

$emailFrom = FilterCChars("$FTGemail");

 

$emailHeader = "From: $emailFrom\n"

  . "MIME-Version: 1.0\n"

  . "Content-type: text/plain; charset=\"ISO-8859-1\"\n"

  . "Content-transfer-encoding: 8bit\n";

 

mail($emailTo, $emailSubject, $emailBody, $emailHeader);

 

 

# Redirect user to success page

 

header("Location: http://www.craigperry.com/newsite/consultation_thankyou.htm");

exit;

?>

put this in your <head>

<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
return false;
}
//-->
</SCRIPT>

then use this in your if statement:

if ($ValidationFailed === true) {

echo '<script>return popup(this, 'notes')</script>';

} 

Thank you tail.

 

Do you know if this will work if I call the javascript from an external .js file? Also would it be similar for the Thank You page as well:

 

# Redirect user to success page

 

header("Location: http://www.craigperry.com/newsite/consultation_thankyou.htm");

exit;

 

 

Ok, now this may seem retarded, but within the JS Script you sent is the mylink suppose to be the link to the popup page I want?

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.