stockton Posted January 12, 2009 Share Posted January 12, 2009 I have created a program using the example at http://www.tizag.com/phpT/examples/formfinale.php as follows:- <?php /* * A program, written by Alf Stockton, to proove that it is possible to run * a program on a remote site from a program on this site, passing to the * remote program whatever parameters it requires to run successfully. * * This then for the Khulisa site, removes the requirement for memcache * or similar. */ ob_start(); if (!empty($_REQUEST['submit'])) $Button = ($_REQUEST['submit']); else $Button = ''; // echo "Button = ".$Button." ??"; if ($Button == 'Submit') { $Button = $_REQUEST['submit']; session_start(); ob_start(); $quote = 0x27; // authenticate. if (!get_magic_quotes_gpc()) { $_REQUEST['uname'] = addslashes($_REQUEST['uname']); } $uname = $_REQUEST['uname']; $passwd = strip_tags($_REQUEST['passwd']); $passwd = stripslashes($_REQUEST['passwd']); $date = date('Y-m-d H:i:s'); $_SESSION['Usrname'] = $uname; $_SESSION['Passwrd'] = $passwd; $_SESSION['Date'] = $date; header("Location: http://motrain.dev.sharing.org.za/test/dong.php"); } else if ($Button == 'Clear') // Clear Previous { $Ding = 0; $uname = ""; $passwd = ""; $date = ""; } ob_end_flush(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>Login</title> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="Mon, 22 Jul 2000 11:12:01 GMT"> <script language="JavaScript" type="text/javascript" src="js/Diva.js"></script> </head> <BODY ONLOAD="BodyOnLoad()"> <form name='logon' id='logon' method='POST' action='<?php echo $PHP_SELF; ?>' > <table align="center" border="3" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td> <input type="text" name="uname" id="uname" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="passwd" id="passwd" maxlength="50"> </td></tr> <input type=hidden name="submit1" id="submit1" value="<?php echo $Ding; ?>" > </td></tr> </table> <center> <p> <input type="submit" name="submit" value="Submit"> <input type="submit" name="submit" value="Clear"> <input type="submit" name="submit" value="Back"> </p> </center> </form> </body> </html> <script type="text/javascript"> function BodyOnLoad() { document.logon.uname.focus(); } </script> I now need to retrieve the entered data via <?php $uname = $_POST["uname"]; $passwd = $_POST["passwd"]; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <title>motrain's Test</title> <meta name="author" content="Alf Stockton"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="Mon, 22 Jul 2000 11:12:01 GMT"> </head> <h2>MOTRAIN's Test</h2> <center> Have a Good Day<?php echo " $uname with password $passwd." ?> </center> </body> </html> but do not get any data back. What have I done wrong? Link to comment https://forums.phpfreaks.com/topic/140474-retrieving-data-from-a-page-after-using-php-_postsubmit/ Share on other sites More sharing options...
anfo Posted January 14, 2009 Share Posted January 14, 2009 I noticed that in the first script there are $_REQUEST superglobals and in the second you are using $_POST. this could be the problem. the other thing is in the second script there's no session start() and as far as I can see no way of accessing the information in those session variables setup in the first script. Hope this helps Anfo Link to comment https://forums.phpfreaks.com/topic/140474-retrieving-data-from-a-page-after-using-php-_postsubmit/#findComment-736788 Share on other sites More sharing options...
stockton Posted January 14, 2009 Author Share Posted January 14, 2009 I suspect that the problem is that the 1st program is not submitting a form but rather doing a call to the 2nd machine on a different server. Therefore the code should be altered as follows:- header("Location: http://motrain.dev.sharing.org.za/test/dong.php"); should now become :- header("Location: http://motrain.dev.sharing.org.za/test/dong.php?uname=$uname&passwd=$passwd"); and therefore the 2nd program should be altered to:- $uname = $_GET["uname"]; $passwd = $_GET["passwd"]; from:- $uname = $_POST["uname"]; $passwd = $_POST["passwd"]; This is all because session variables are only available on the 1st machine and any data required on the 2nd machine must be passed via $_GET rather than form submission. Link to comment https://forums.phpfreaks.com/topic/140474-retrieving-data-from-a-page-after-using-php-_postsubmit/#findComment-736804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.