473,508 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a Popup in PHP

36 New Member
I basically have a mail to form on my website. When the form is filled and submitted by the user it processes the form using the file feedback.php. What i want is a Pop up window which says "thank you for your Feedback" for 5 second and then goes back to the home page... Below is the code for the feedback.php

[PHP]<?php
/*
CHFEEDBACK.PHP Feedback Form PHP Script Ver 2.08
Generated by thesitewizard.com's Feedback Form Wizard.
Copyright 2000-2007 by Christopher Heng. All rights reserved.
thesitewizard and thefreecountry are trademarks of Christopher Heng.

Get the latest version, free, from:
http://www.thesitewizard.com/wizards/feedbackform.shtml

You can read the Frequently Asked Questions (FAQ) at:
http://www.thesitewizard.com/wizards/faq.shtml

I can be contacted at:
http://www.thesitewizard.com/feedback.php
Note that I do not normally respond to questions that have
already been answered in the FAQ, so *please* read the FAQ.

LICENCE TERMS

1. You may use this script on your website, with or
without modifications, free of charge.

2. You may NOT distribute or republish this script,
whether modified or not. The script can only be
distributed by the author, Christopher Heng.

3. THE SCRIPT AND ITS DOCUMENTATION ARE PROVIDED
"AS IS", WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE
IMPLIED WARRANTY OF MECHANTABILITY OR FITNESS FOR A
PARTICULAR PURPOSE. YOU AGREE TO BEAR ALL RISKS AND
LIABILITIES ARISING FROM THE USE OF THE SCRIPT,
ITS DOCUMENTATION AND THE INFORMATION PROVIDED BY THE
SCRIPTS AND THE DOCUMENTATION.

If you cannot agree to any of the above conditions, you
may not use the script.

Although it is not required, I would be most grateful
if you could also link to thesitewizard.com at:

http://www.thesitewizard.com/

*/

// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto = "youremailaddress@example.com" ;

$mailto = 'atiq@hotmail.com' ;

// $subject - set to the Subject line of the email, eg
//$subject = "Feedback Form" ;

$subject = "Feedback" ;

// the pages to be displayed, eg
//$formurl = "http://www.example.com/feedback.html" ;
//$errorurl = "http://www.example.com/error.html" ;
//$thankyouurl = "http://www.example.com/thankyou.html" ;

$formurl = "http://atiq.netcafe.eu/contactEmail.html" ;
$errorurl = "http://atiq.netcafe.eu/error.html" ;
$thankyouurl = "http://atiq.netcafe.eu/" ;

$uself = 0;

// -------------------- END OF CONFIGURABLE SECTION ---------------

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}

if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------ COMMENTS ------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: feedback.php 2.08" );
header( "Location: Location: $thankyouurl")
exit ;

?>[/PHP]


Any help would be appreciated!
Thanks
Mar 19 '08 #1
4 6667
arggg
91 New Member
you could use a hidden div and when the email is sent unhide the div and display "Thank you for submitting an email". Then you can include the

Expand|Select|Wrap|Line Numbers
  1.  <meta http-equiv="refresh" content="5;url=http://urlhere"/>

however many see meta refresh as abusive and much like spam. So you can also use php
Expand|Select|Wrap|Line Numbers
  1. header("refresh: 5; thankyou.htm");
which will send the page to your main url after 5 seconds.
Mar 19 '08 #2
gXion
5 New Member
for me..
this works

you could replace lines 106-109
with this code

[PHP]if(mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: feedback.php 2.08" )
{
?>
<script language="javascript">
window.open ("thank.html","mywindow","location=1,status=0,scro llbars=0,width=400,height=400");
</script>
<?
$thankyouurl = 'http://www.google.com';
echo '<meta http-equiv="refresh" content="5;url='.$thankyouurl.'">'
}
else
{// to prevent some hacking stuff

}[/PHP]

then create a thank.html
with this code:

[HTML]<html>
<head>
<script language="javascript">
settimeout("window.close()",5000)
</script> </head>
<body>
thanks for whatever.
</body>
</html>[/HTML]

hope this help.
Mar 19 '08 #3
Atli
5,058 Recognized Expert Expert
Hi.

gXion's solution will most likely do what you are asking for.
Tho, I would recommend replacing the <meta> refresh tag at line 10 with:
Expand|Select|Wrap|Line Numbers
  1. header("refresh: 5; $homepageurl");
  2.  
(And replace the <? tags with <?php)

Having said that, you may want to consider an alternative.
Many browsers have an annoying habit of ignoring pop-ups and meta refresh commands, so you would probably be better of without them.

Consider this (excuse my excessively detailed style :P):
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   $homepageurl = "http://www.example.com/index.php";
  3.   header("Refresh: 5; $homepageurl");
  4. ?>
  5. <div 
  6.     style="
  7.         position: absolute; 
  8.         left: 100px;
  9.         top: 50px;
  10.         width: 400px;
  11.         height: 200px;
  12.         background-color: #00AA22; 
  13.         color: #CCFFCC;
  14.         font-size: 20px;
  15.         font-weight: bold;
  16.         text-align: center;
  17.         line-height: 200px; 
  18.         padding: 5px; 
  19.         border: 5px black double;
  20.     "
  21. >
  22. Something just succeded!
  23. </div>
  24.  
This creates a popup like DIV in a otherwise normal page, which is redirected to you homepage after 5 seconds, without having to create any extra windows or add any <meta> tags.

Note that this div will be displayed in the same place even if it has to cover other stuff to do so.
Mar 20 '08 #4
atiq
36 New Member
Hi.

gXion's solution will most likely do what you are asking for.
Tho, I would recommend replacing the <meta> refresh tag at line 10 with:
Expand|Select|Wrap|Line Numbers
  1. header("refresh: 5; $homepageurl");
  2.  
(And replace the <? tags with <?php)

Having said that, you may want to consider an alternative.
Many browsers have an annoying habit of ignoring pop-ups and meta refresh commands, so you would probably be better of without them.

Consider this (excuse my excessively detailed style :P):
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   $homepageurl = "http://www.example.com/index.php";
  3.   header("Refresh: 5; $homepageurl");
  4. ?>
  5. <div 
  6.     style="
  7.         position: absolute; 
  8.         left: 100px;
  9.         top: 50px;
  10.         width: 400px;
  11.         height: 200px;
  12.         background-color: #00AA22; 
  13.         color: #CCFFCC;
  14.         font-size: 20px;
  15.         font-weight: bold;
  16.         text-align: center;
  17.         line-height: 200px; 
  18.         padding: 5px; 
  19.         border: 5px black double;
  20.     "
  21. >
  22. Something just succeded!
  23. </div>
  24.  
This creates a popup like DIV in a otherwise normal page, which is redirected to you homepage after 5 seconds, without having to create any extra windows or add any <meta> tags.

Note that this div will be displayed in the same place even if it has to cover other stuff to do so.
I made the changes but when it processed the feedback.php it frezzed (stoppped). below is the code:

[PHP]
// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto = "youremailaddress@example.com" ;

$mailto = 'atiqisthebest@hotmail.com' ;

// $subject - set to the Subject line of the email, eg
//$subject = "Feedback Form" ;

//$subject = "Feedback by $name" ; ***MOVED to line 78***

// the pages to be displayed, eg
//$formurl = "http://www.example.com/feedback.html" ;
//$errorurl = "http://www.example.com/error.html" ;
//$thankyouurl = "http://www.example.com/thankyou.html" ;

$formurl = "http://atiq.eu/contactEmail.html" ;
$errorurl = "http://atiq.eu/error.html" ;
$thankyouurl = "http://atiq.eu/" ;

$uself = 0;

// -------------------- END OF CONFIGURABLE SECTION ---------------

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

$subject = "Feedback by $name" ;

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}

if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------ COMMENTS ------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: feedback.php 2.08" );
//header( "Location: $thankyouurl" );
header( "
$homepageurl = "http://www.atiq.eu";
header("Refresh: 5; $homepageurl");
?>
<div
style="
position: absolute;
left: 100px;
top: 50px;
width: 400px;
height: 200px;
background-color: #00AA22;
color: #CCFFCC;
font-size: 20px;
font-weight: bold;
text-align: center;
line-height: 200px;
padding: 5px;
border: 5px black double;
"
>
Something just succeded!
</div>[/PHP]

How can i get around this?

Any help would be Appreciated!

Thanks
Mar 20 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1691
by: Logger | last post by:
Help! I’m trying to get popups to work in asp.net. I’m Using the following javascript code in a sub, but I can’t get the PopupWindow to work. At first I thought the routine wasn’t...
24
3213
by: jonathon | last post by:
Hi all, I have a web app with a popup window for entering data. I don't want to access the web every time this window is opened, as most of the app is AJAX. But I can't figure out how to open...
4
5125
by: Jeremy Weiss | last post by:
Thanks to much help from everyone in my previous thread, I've made it a pretty fair ways into my billing/invoicing db. I'm now needing a way to cycle through all the records in a table and create...
1
6662
by: Angel | last post by:
How can I create a popup window similar to the 'Insert Comment' dialog in MS Excel? I only need it to popup, and it should have an OK button. Would that be a Windows form or a user control? ...
8
1842
by: David W. Simmonds | last post by:
Is there an easy way to create a new browser window from C# and ASP.NET? I would just like to have a popup window without any menus or toolbars that would contain a high-res image. The low-res...
2
1782
by: GMK | last post by:
HI ALL I'M COMING FROM A FOX PRO BACKGROUND WHERE I COULD IN A VERY EASY WAY CREATE A SEACH FACILITY BY PRESSING N F1 AND ANOTHER WINDOW WILL DIRECTLY APPEAR WHICH WOULD LET THE USER TO SEARCH...
4
1292
by: Sam Learner | last post by:
Hi Everyone, I'd like to create my own Internet Popup windows Stopping program. Is there any code I could you to monitor when IE or Netscape opens a Windows from a clicked Link? how about managed...
0
1314
by: .nu | last post by:
#!/usr/bin/env python # -*- coding: utf-8 -*- # Name: Sleepy Hollow # Author: .nu import wx import os import sys
3
3062
by: tapan roy | last post by:
i will creating a popup menu in php script and content in mysql table. how i creat a popup menu in a table content show the following pattern. FILE MASTER EXIT ENTRY1 ...
1
2949
by: ata | last post by:
Hi, I need to create a PopupControlExtender dynamically, and attach it to a LinkButton. i.e., when the LinkButton is clicked, I would like to display a given literal control to the user. So, I...
0
7229
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7129
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.