I am calling child page and posting the form. Trying to refresh and rebuild the parent page based on value entered in child page. I am not able to see the child posted values in Parent page.
Expecting value $_POST[‘test_2’] populated when child is submitted from Parent page.
I don’t see the value posted by child page in parent page. See the code example below.
Thanks for your help..
Advice me if there are any other better way to access the value submitted by child page and rebuilding the parent page using those child page values.
Parent Page is : Example1Parent.php
<html>
<head>
<body>
<h1> Welcome Parent </h1>
<div id="dateDiv"></div>
<form method=post action='' name=f1>
<table border=0 cellpadding=0 cellspacing=0 width=550>
<tr>
<td ><font size=2 face='Verdana'>Refresh upon Search</font>
<input type=hidden name='p_name2' id=n2 size='8'>
<input type=button
onClick=window.open("Example1Child.php","Ratting","width=550,height=170,left=150,top=200,toolbar=0,status=0,"); value="Advanced Search">
<?php
echo '<br> Welcome ';
if (!isset($_POST['test_2'])) echo "<br> t_test2 : it does not exists! ";
?>
</td></tr>
</table>
</form>
</body>
</html>
Child Page is :Example1Child.php
<html>
<head>
<title>ChildForm</title>
<SCRIPT language=JavaScript>
<!--
function win(){
window.opener.location.href="Example1Parent.php";
self.close();
//-->
}
</SCRIPT>
</head>
<body>
<h1> Welcome to Child </h1>
<form name="child" id="child" METHOD="POST" action=''>
<input type="text" id="test_2" name="test_2" value="ENTER DATA TO PARENT PAGE">
<INPUT TYPE="SUBMIT" onClick="win();" value="SEND VALUE TO PARENT">
</form>
</body>
</html>
as tmuguet mentioned you might want to create a different method since this is a fairly old way of doing this. Now a days you can have popups/modal boxes and such to get a value then update the page with js/ajax or whatnot.
I’m guessing you are trying to pass values through windows via js which won’t work since you open the window opening a clean link (no values passed even tough you have ‘POST’ in the form method) and you can use something like the following, but it will only give you GET values
What you are looking for is something like Window.open and pass parameters by post method problem
I have not tested this script
You might want to do a
var_dump($_POST)in your Example1Parent.php file to see iff.test_2.valuetranslates to$_POST['test_2']