Jump to content

code bug after upgrade from PHP 5.1 to 5.2


wipe

Recommended Posts

Hi guys,

 

a few days i upgrade php from 5.1 to 5.2.16

all seem fine and last 2 days i start to find some bugs.

I use this code to get url var and pass from a form:

                <?php
				  echo $_GET['id'];
?>            
                <input name="ids" type="hidden" id="ids" value="<?php $_GET['id'];?>" />

 

In the email i receive all data from the form, but not this that i get from the URL.

 

in code to send to email i just use:

$_POST[id] 

 

This work fine in 5.1 but not in this version.

 

anyone have an idea why?

 

Wipe

Look to the HTML of the form. It should be:

<form action="" method="">

 

If 'method' is not defined, default it is set to 'get', and then you have to collect the variable with $_GET['id']. If the method is set to 'post', then you have to fetch the variable with *_POST['id']. You could also choose to fetch the variable with $_REQUEST['id'] - this predefined variable holds the content of $_POST, $_GET and $_COOKIE.

You need to actually echo the value here:

 

<input name="ids" type="hidden" id="ids" value="<?php $_GET['id'];?>" />
// should be 
<input name="ids" type="hidden" id="ids" value="<?php echo $_GET['id'];?>" />

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.