Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 451
  • Last Modified:

How to make a php message display in new window

When people submit a short form on my site they receive a message on a new page  in the same browser window and need to use the back button to return to the site. How can I make the message popup just near the form when they click submit?

php code below
0
TonyCabone
Asked:
TonyCabone
  • 4
  • 2
1 Solution
 
Ionut A. TudorPHP ProgrammerCommented:
0
 
agamalCommented:
you don't need a pop up window you can use


header to redirect the user back after reading the message



if you need to open it in new window you can use Java script or HTML link

ex2:
// 2 is the seconds waiting between refresh
<meta http-equiv="refresh" content="2;url=http://www.ee.com">
 
ex2:
// 10 is the seconds waiting between refresh
header("refresh: 5; url=http://www.ee.com");

Open in new window

0
 
TonyCaboneAuthor Commented:
where do i place header code?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
agamalCommented:
depending on the page code .. if you can post the code i can send it back edited
0
 
TonyCaboneAuthor Commented:
sure agamal here it is buddy, slightly minimized
<?php
if( isset($_POST['Submit']) )
{
        $to="info@asbc.net.au";
        $subject="Registered interest for 2009 Dorwin Gold Cup";
        unset($_POST['Submit']);
        $message=array();
        foreach($_POST as $k => $v){
                $message[]="{$k}:{$v}";
        }
        $message=implode("\r\n",$message);
        if( !mail($to,$subject,$message) )
        {
                die("unable to send email");
        }
        else
        {
                die("<h1>Thank you!<br />Please use the Back button on your browser to return to the site</h1>");
				header("refresh: 5; url=http://www.asbc.net.au/news/dorwin09.php");
				
        }
        
}
?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="registerQuarterMile" id="registerQuarterMile">
      <strong>SPECTATORS &amp; COMPETITORS</strong> <br />
      Please complete the fields below. It helps us make things better for everyone!
      <table>
        <tr>
          <td><div align="right">Name</div></td>
          <td><input name="Name" type="text" id="Name" /></td>
        </tr>
        <tr>
          <td><div align="right">Phone</div></td>
          <td><input name="Phone" type="text" id="Phone" /> 
          (optional) </td>
        </tr>
        <tr>
          <td><div align="right">Email</div></td>
          <td><input name="Email" type="text" id="Email" /> 
          (optional)</td>
        </tr>
        <tr>
          <td colspan="2">Are you interested in attending this event as a spectator?<label><input type="radio" name="interestedSpectator" value="Yes" />
          Yes</label>
                <br />
                <label>
                <input type="radio" name="interestedSpectator" value="No" />
          No</label>
                <p><input name="Submit" type="submit" id="Submit" value="Submit" />
                                </p>
                </td>
          <br />
        </tr>
        <tr>
          <td colspan="2"><strong>RACE BOAT OWNERS </strong></td>
        </tr>
        <tr>
          <td colspan="2">Are you interested in competing in the Dorwin Gold Cup?
            <label><input type="radio" name="interested competitor" value="Yes" />
          Yes</label>
                <br />
                <label>
                <input type="radio" name="interested competitor" value="No" />
          No</label>
            </td>
          <br />
        </tr>
        <tr>
          <td><div align="right">Boat name:</div></td>
          <td><input name="Boat name" type="text" id="Boat name" /></td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
      </table>
      <input name="Submit" type="submit" id="Submit" value="Submit" />
    </form></head></html>

Open in new window

0
 
agamalCommented:
you can make it like this


it will redirect the user after 5 seconds
header("refresh: 5; url=http://www.asbc.net.au/news/dorwin09.php"

if you want to change 5 seconds change refresh:5 to any other number

<?php
if( isset($_POST['Submit']) )
{
        $to="info@asbc.net.au";
        $subject="Registered interest for 2009 Dorwin Gold Cup";
        unset($_POST['Submit']);
        $message=array();
        foreach($_POST as $k => $v){
                $message[]="{$k}:{$v}";
        }
        $message=implode("\r\n",$message);
        if( 1 != 1)
        {
                die("unable to send email");
        }
        else
        {
            header("refresh: 5; url=http://www.asbc.net.au/news/dorwin09.php");
            echo "<h1>Thank you!<br />Please use the Back button on your browser to return to the site</h1>";
 
 
        }
 
}
?>

Open in new window

0
 
agamalCommented:
or you can make it like this if you want it in pop up window

here is the code ....

put you will need to make a separate page containing Thank you massage and place its URL instead of

http://www.testsite.com/welcomepage.php



<?php
//if( isset($_POST['Submit']) )
//{
        $to="info@asbc.net.au";
        $subject="Registered interest for 2009 Dorwin Gold Cup";
        unset($_POST['Submit']);
        $message=array();
        foreach($_POST as $k => $v){
                $message[]="{$k}:{$v}";
        }
        $message=implode("\r\n",$message);
        if( 1 != 1)
        {
                die("unable to send email");
        }
        else
        {
         header("refresh: 0; url=http://www.asbc.net.au/news/dorwin09.php");        
        ?>
        <script>
            window.open('http://www.testsite.com/welcomepage.php','mywindow','width=400,height=200')
        </script>
          <?php
        }
//}
?>

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now