Form doorgeven aan windowopener
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
if(isset($_GET['nieuw'])){
echo("
<head>
<title>Offerteaanvraag toevoegen</title>
<link rel='stylesheet' type='text/css' href='includes/styles.inc.css' />
<script language=\"javascript\">
function to_old_win(url) {
opener.location.href = url;
window.close();
}
</script></head>");
echo("<form method=post action='javascript:to_old_win
(\"" . $_SERVER['PHP_SELF'] . "?ingevuld=ingevuld\");window.close;''>
<input type=text name=hallo value=hallo>
<input type=submit value=Verzenden></form>");
}elseif(isset($_GET['ingevuld'])){
print_r($_POST);
}else{
echo("<a href=\"javascript:void(window.open('" . $_SERVER['PHP_SELF'] . "?nieuw=nieuw','newWin','scrollbars=1,width=700,height=800,top=60,left=60'))\">HIER</a>");
}
?>
if(isset($_GET['nieuw'])){
echo("
<head>
<title>Offerteaanvraag toevoegen</title>
<link rel='stylesheet' type='text/css' href='includes/styles.inc.css' />
<script language=\"javascript\">
function to_old_win(url) {
opener.location.href = url;
window.close();
}
</script></head>");
echo("<form method=post action='javascript:to_old_win
(\"" . $_SERVER['PHP_SELF'] . "?ingevuld=ingevuld\");window.close;''>
<input type=text name=hallo value=hallo>
<input type=submit value=Verzenden></form>");
}elseif(isset($_GET['ingevuld'])){
print_r($_POST);
}else{
echo("<a href=\"javascript:void(window.open('" . $_SERVER['PHP_SELF'] . "?nieuw=nieuw','newWin','scrollbars=1,width=700,height=800,top=60,left=60'))\">HIER</a>");
}
?>
Nu moet het script die $_POST['hallo'] weergeven bij $_GET['ingevuld'], alleen doet hij dat niet. Hoe moet ik het script aanpassen zodat hij wel de form doorgeeft?
windows.open ?waarde1=$_POST['waarde1']....
even vlug gemaakt, als je het niet snapt, zeg even, dan schrijf ik hem uit
schrijf maar even uit ;)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
session_start();
?>
<html>
<head>
<title>Bla</title>
<SCRIPT LANGUAGE='JAVASCRIPT' TYPE='TEXT/JAVASCRIPT'>
<!-- Dit pop-up script komt van de opup generator op leejoo.nl
var win=null;
function NewWindow(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();}
// -->
</script>
</head>
<body>
<form action="#" method="post">
<label> Veld 1: <input name="veld1" type="text" /></label><br />
<label> Veld 2: <input name="veld2" type="text" /></label><br />
<label> Veld 3: <input name="veld3" type="text" /></label><br />
<br />
<input name="submit" type="submit" value="test!" />
</form>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$i = 0;
$string = NULL;
foreach($_POST as $key => $value)
{
if($key != 'submit' && !empty($value))
{
$_SESSION['popup'][$key] = $value;
}
$i++;
}
echo '<a href="#" onclick="NewWindow(\'popup.php\',\'popupnaam\',\'700\',\'800\',\'custom\',\'front\')">klik hier</a>';
}
?>
</body>
</html>
session_start();
?>
<html>
<head>
<title>Bla</title>
<SCRIPT LANGUAGE='JAVASCRIPT' TYPE='TEXT/JAVASCRIPT'>
<!-- Dit pop-up script komt van de opup generator op leejoo.nl
var win=null;
function NewWindow(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();}
// -->
</script>
</head>
<body>
<form action="#" method="post">
<label> Veld 1: <input name="veld1" type="text" /></label><br />
<label> Veld 2: <input name="veld2" type="text" /></label><br />
<label> Veld 3: <input name="veld3" type="text" /></label><br />
<br />
<input name="submit" type="submit" value="test!" />
</form>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$i = 0;
$string = NULL;
foreach($_POST as $key => $value)
{
if($key != 'submit' && !empty($value))
{
$_SESSION['popup'][$key] = $value;
}
$i++;
}
echo '<a href="#" onclick="NewWindow(\'popup.php\',\'popupnaam\',\'700\',\'800\',\'custom\',\'front\')">klik hier</a>';
}
?>
</body>
</html>
Dit bestand kun je noemen zoals je wilt.
Code (php)
Dit bestand is popup.php
Deze manier is veiliger dan mijn orspronkelijke manier, omdat ik hier de waardes in sessions op de server zet, en niet in de url.
Gewijzigd op 01/01/1970 01:00:00 door PHP Newbie