473,667 Members | 2,703 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.c om'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.thesitewiza rd.com/wizards/feedbackform.sh tml

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

I can be contacted at:
http://www.thesitewiza rd.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.c om at:

http://www.thesitewiza rd.com/

*/

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

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

$mailto = 'atiq@hotmail.c om' ;

// $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.ht ml" ;
$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_REFER ER" );

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_quot es_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 6692
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="javas cript">
window.open ("thank.html"," mywindow","loca tion=1,status=0 ,scrollbars=0,w idth=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="javas cript">
settimeout("win dow.close()",50 00)
</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 = "youremailaddre ss@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.ht ml" ;
$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_REFER ER" );

$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_quot es_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
1707
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 working but it is. It looks like it’s the window.open that’s not working. I have site popup allowed turned on, if I replace window.open with alert it works, if I put the code in the html code it works. Any suggestions? Dim PopupScript As String...
24
3244
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 a new window and build it with DOM rather than having to provide a src. Even a blank.html as src takes time to fetch. How can I create a popup and dynamically add DOM content without any html at all?
4
5137
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 invoice records for them in another table, but I have no idea where to begin. Here's the relevant tables: ============== Table: Customer_tbl
1
6672
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? Thanks.
8
1853
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 image would be in the main window and would have a button that when pressed brings up the "popup" window that has the high-res image. I would like the window to be re-used instead of creating yet another popup window if the user navigates to another...
2
1794
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 FRO A SPECIFIC DATAVALUE AND INSERT IT IN A TEXTBOX IN THE ORIGINAL FORM. I WOULD LIKE TO CREATE A SIMILAR FACILITY IN ASP.NET I DON'T WANT A KEYPRESS FUNCTION I COULD CREATE A BUTTON ON THE SCREEN BUT I WANT TO CREATE A POPUP WINDOW WHERE I COULD...
4
1305
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 class, is there any? Please help. SJ
0
1330
by: .nu | last post by:
#!/usr/bin/env python # -*- coding: utf-8 -*- # Name: Sleepy Hollow # Author: .nu import wx import os import sys
3
3075
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 ENTRY2
1
2960
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 tried the following code: LinkButton link = new LinkButton(); link.ID = "imgOtherAttributes" + caid; link.CausesValidation = false; link.Text = "other options";
0
8367
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8889
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8570
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7391
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2781
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 we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.