Hi,
i'm working on page, where I need to add contact-form.
I've used code from NiceAndSimpleForm, i mean

<?php

$EmailFrom = "blablabla";
$EmailTo = "blablabla";
$Subject = "blablabla";
$Name = Trim(stripslashes($_POST['Name'])); 
$City = Trim(stripslashes($_POST['City'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// prepare email body text
$Body = "";
$Body .= "Imię i nazwisko: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Miejscowość: ";
$Body .= $City;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Wiadomość: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if($success){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

and the problem is, that I want to have new window open with communicate that operation is succeed.
I guess I need to create a new html film, which will pop-up after message is sent, but I don't have an idea how to add line about this to quoted php file. need to use 'function popitup(url)', but how in php file?

Sorry for my english...

take care

change the 31-33line to this

// redirect to success page

if($success){
   // try this 
@header("location:success_page.php?name=$username");// Direct to a new page 
//echo "We've recived your contact information";

}

then have a success.php to recieve the get variable .

$foo=$_GET['name'];

echo "Thank you $foo<br/";
echo "You win the price"; Bla bla etc......

you get the idea ?
You can do all on the same file anyway.

Explore ;)

Thanks dude. But I've got one problem, I've wanted to get pop-up window with predefined window size. And with your code, I get success.php in the same browser window.

pop mmm you need javascript.

do you need one?

Explore :)

pop mmm you need javascript.

do you need one?

Explore :)

Yes, I usually used

<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
	newwindow=window.open(url,'name','height=500px,width=1000px');
	if (window.focus) {newwindow.focus()}
	return false;
}

and with <a> <a href="x.html" onclick="return popitup('x.html')">click</a> but i don't know how to add this to php document... sorry if my question is stupid, but i'm a really beginner with php.

Try this
put all the javscript into a php variable;

<?php
$foo="    <script language='javascript' type='text/javascript'>
<!--
function popitup(url) {
    newwindow=window.open(url,'name','height=500px,width=1000px');
    if (window.focus) {newwindow.focus()}
    return false;
}
</script>
";

?>

And echo it where needed.

I am awaiting for your outcome.

Explore :)

Hm, still get out put in the same window. Maybe I'm doing something wrong, I've got contactengine.php that I've pasted in the first posted, changed in the way you advice me

// redirect to success page

if($success){
   // try this 
@header("location:success.php?name=$username");// Direct to a new page 
//echo "We've recived your contact information";

}

and I've got success.php with

<?php
$foo="    <script language='javascript' type='text/javascript'>
<!--
function popitup(url) {
    newwindow=window.open(url,'name','height=500px,width=1000px');
    if (window.focus) {newwindow.focus()}
    return false;
}
</script>
";
echo "Thank you $foo<br/";
echo "You win the price";

?>

The problem can't be form which is in the other HTML file? I mean, there is also few fields and submit button. Take care

Hm?

There is a way...

Javascript for some reasons will not work just embedding like that.

if you really want the popup.

do the php header("location:foo.php");

put your popup on foo.php head tag your javascript function.
The popup.php which will take the redirection and produce the popup for you.

1. This means the popup.php will do the popup . that is new window basesd on what ever you name it.

2. put in html body tag action to run the java script function. <body onload='java function'>

Bingo :)

You get the pop up.
you can add all you variables to get the on the new popup window!!

you feel me :)

I am waiting :)

Slower, dude ;).

I've got three files, contact.html foo.php and contactengine.php
1. I replaced <body> with <body onload='java function'> in contact.html file.

2. My contactengine.php (which I mentioned in a first post) has lines

if($success){
   // try this 
@header("location:foo.php");
}

3. My foo.php is

<?php
$foo="    <script language='javascript' type='text/javascript'>
<!--
function popitup(url) {
    newwindow=window.open(url,'name','height=500px,width=1000px');
    if (window.focus) {newwindow.focus()}
    return false;
}
</script>
";
echo "Thank you $foo<br/>";
echo "You win the price";

?>

4. And still, the same, I'm getting output in the same window, not in a popup.

What am I doing wrong?

No no no You are not doing what i just told you.

That should work 100%;

Please follow carefully.

1.yes you need 3 files for this.

how do you go about this.???

Read this.

1.you have your first form that will do the redirection with the php
header function based on success. This will redirect to redirect.php file.

2. on the redirect.php file, it must contain a full html snippet.
a.put the java script in the head as usual.
b. go to the body tag and on onload <body onload="function popup">
</body>
3. You must have the popup file created and must be referenced inside you javacsript function

This will do what you wanted. :)

Oh, thanks, now I understand. Only one, and last question, how should look my redirect.php file,
I know that there is a mistake, but I don't know how set this popup on load on right url (foo.php).

<html>
<head>
<script language='javascript' type='text/javascript'>
<!--
function popitup(url) {
    newwindow=window.open('foo.php','name','height=500px,width=1000px');
    if (window.focus) {newwindow.focus()}
    return false;
}
</script>

</head>


<body onload="function popitup">
</body>
</html>

Sorry for all of this, I'll be your debtor...

just change the code and use it exactly like you see.

<html>
<head>
 <title>JavaScript Popup Example 3</title>

<SCRIPT language="JavaScript1.2">
function poponload()
{
testwindow= window.open ("", "mywindow", // you start with your http and also you add your get variables
    "location=1,status=1,scrollbars=1,width=100,height=100");
testwindow.moveTo(0,0);// your position
}
</SCRIPT>
</head>
<body onload="javascript: poponload()">

</body>
</html>

This should work :)

hi all
i have ticket management page like this
"edit_ticket_info.php"
in this page I can update the values of my ticket except the resolution date and time of the ticket.

now i want to change the date and time of the ticket by using a pop up window where in new window it will select the ticket from my database and show its resolution time in a box.

then i will give the new date and time if the ticket status is set as pending. and on submit it will returnt to edit_ticket_info.php page updating all the values...

i got some javascript to create new window. but i am unable to pass the ticket number to that new window.. also database is not taking the inputs from that pop up window.

please help me...

i dont know much about javascript.. here is code for opening new window that i got from internet

<a href="http://localhost/pendig_tracker_time.php" onclick="javascript:void window.open('http://localhost/pendig_tracker_time.php','1342848783361','width=700,height=500,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;">Pop-up Window</a>

thank you

Hello,
use below code:

$url="pendig_tracker_time.php";

    if($success)
    {

            echo "<script>
                           popitup('$url');
            </script>";

    }

Sorry @raj. i didn't understand.where to put these codes... can explain a little bit more..

This should work :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.