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++;
  ?>
  }
  ?>

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.