Jump to content

PHP Help required... display php form data


rebeat

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.