rebeat Posted March 23, 2007 Share Posted March 23, 2007 Hi, I recently installed PHP5 (5.1.6) What i need to do is submit a form then display the contents for review. Basically i had it working on php 4.4 but now it just presents a blank page. as example at: http://yournetworth.org/test.php?name=123 how do i display name (ie: 123) in the page? i have tried a few different importing methods: <? $name?> <?php print "name is: ". $name; ?> <?php $_GET['name'] ?> all i get is blank is there a module i am missing? briefly, the form page, example checkout.php: <form action="test.php" method="put"> <input type=text name=name value=123> <input type=submit> the test.php page should display the value, ie: name = 123 as i said, i had no problems using the above method with PHP4 Any ideas? Thank You. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 23, 2007 Share Posted March 23, 2007 The default for register_globals went from enabled to disableed. You now have to retrieve values defined in forms or on the URL directly from either the $_POST or $_GET superglobal array. The $_POST array is for forms with 'method="post"', the $_GET array is form forms with 'method="get"' and values on the URL. In your case, I assume you meant ''method="post"', not ''method="put"', so you would need: <?php if (isset($_POST['name'])) echo 'name is: ' . $_POST['name']; ?> <form action="test.php" method="post"> <input type="text" name="name" value="123"> <input type="submit" name="submit"> Ken Quote Link to comment Share on other sites More sharing options...
TecBrat Posted March 23, 2007 Share Posted March 23, 2007 I have used this, but be sure you understand the reason register_globals was turned off, and the security risks of using this snippet. (That mainly being that a person can guess a variable name, and guess an intended value and put it in the query string and gain access where it's not intended like www.test.com/?authorized=yes&level=admin where "authorized" and "level" should have been set by the program, and not trusted as GET vars. <? foreach($_POST AS $key => $value) { ${$key} = $value; } foreach($_GET AS $key => $value) { ${$key} = $value; } ?> If you put that at the top of your script, it will simulate register globals. (for get and post) Make sure to fix your METHOD as mentioned by the previous poster. You want either "get" to put the values in the URL or "post" to have them sent unseen. Quote Link to comment Share on other sites More sharing options...
rebeat Posted March 23, 2007 Author Share Posted March 23, 2007 Thank you Ken and TecBrat, both of those ideas really helped, especially the part about register_globals, at least i know why the problem occured And the code to simulate register_globals is very handy indeed! Thank you both, Cheers, wayne. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.