Jump to content

[SOLVED] How should i call the $_POST of these textboxes


mike12255

Recommended Posts

The number of textboxes displayed depends on a previously entered number by a user. so  i c reated a while statment and made textboxes while i was not equal to n(number entered by the user). I though i was giving the name/id of $i to the textboxes so when i went to call the $_POST of them i used the same method, a while statment calling the $_POST of I and increaseing I each time untill it equals n however my post returns blank each time does anyone know why? Below is my code:

 

<?php

if (isset($_POST['submit'])){
  
  if ($_GET['done'] ==1){
  $amount = $_GET['number'];
  $i=0;
  
include "config.php";
  while ($i != $amount){
  $sql = "INSERT INTO pages (page) VALUES ('".$_POST['$i']."')";
  //mysql_query($sql) or die(mysql_error());
  echo $sql;
  echo $_POST['$i'];
  $i++;
  }
  }
  
  }
  
  
  
  
  
  $n = $_GET['number'];
  $i = 0 ;

  echo "<form action=\"step3.php?done=1&number=$n\" method=\"post\" class=\"form\">";
  
  while($i < $n){
  $over = $i+1;
  echo "<label for=\"username.$i\">Page.$over</label> ";
  echo "<div class=\"div_texbox\">";
  echo "<input name=\"$i\" type=\"text\" class=\"username\" id=\"$i\" />";
  echo "</div>";
  $i++;
  ?>
  }
  ?>

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.