Variable in $_POST

Hi guys, just a quick one, how do I go about echoing the value of the posted field. I’m using PHP_SELF to process the form so wonder if this has anything to do with it. When I press submit, nothing is returned to the page, I loose all the results. Any help massively appreciated! :smiley:

$items = isset($_GET['items']) && ((int)$_GET['items'] > 0) ? (int)$_GET['items'] : 1 ;
<form action="/createorder?items=<?=$items?>" method="post" id="createorder">
<?php foreach(range(0, $items) as $num): ?>
<!-- BOF Product Info -->
<div class="productInfo">
<div class="prodContain">
<span class="fontField bold">Product Description</span>
<input type="text" name="pdname[<?php echo $num; ?>]" value="<?php echo $_POST["pdname[$num]"] ?>" class="prodName" style="width: 280px" />
<!-- EOF Product Info -->
<?php endforeach; ?>

Like this?

ini_set('display_errors', true);

function get_items(){
  $items = array();

  $upper = isset($_GET['items']) && ((int)$_GET['items'] > 0) ? (int)$_GET['items'] : 1 ;

  foreach(range(1, $upper) as $index){

    $value = '';

    if(isset($_POST['pdname']) && is_array($_POST['pdname'])){
        $value = $_POST['pdname'][$index];

        'name'  => sprintf('pdname[%d]', $index),
        'value' => $value

  return $items;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" charset="utf-8" src=""></script>
    <link rel="stylesheet" type="text/css" href="" />
    <link rel="stylesheet" type="text/css" href="" />
    <link rel="stylesheet" type="text/css" href="" />
    <style type="text/css">

    <form action="" method="post">
      <?php foreach(get_items() as $item): ?>
        <input type="text" name="<?php echo $item['name']; ?>" value="<?php echo $item['value']; ?>" /><br />
      <?php endforeach; ?>
      <input type="submit" value="submit" />

Hey dude, yeah bang on, exactly like that! :slight_smile: What did I do wrong :S

At first guess, I would say that pdname[0] doesn’t exist because your $items array starts with $items[1].

A quick view of the outputted html should confirm, or increase ?items= and you’ll probably see the input incorrectly offset.

Ahh right, cool I get you, all working beautifully now. Cheers again, massive help.