-1

Create1.php code

<form action="create2.php" method="POST">
    <table cellpadding="10">
    <tr>
      <td>Name</td>
      <td><input type="text" name="name" value="<?php echo $name; ?>" disabled></td>
    </tr>
    <tr>
      <td>Mobile</td>
      <td><input type="text" name="mobile" value="<?php echo $mobile; ?>" disabled/></td>
    </tr>
    <tr>
      <td>Email</td>
      <td><input type="text" name="email" value="<?php echo $email; ?>" disabled/></td>
    </tr>
    <tr>
      <td>Company</td>
      <td><input type="text" name="company" value="<?php echo $company; ?>"disabled /></td>
    </tr>
    <tr>
      <td><input type="submit" value="Confirm" /></td>
    </tr>
    </table>
    </form>

I am trying to recieve the inputs on my next page, ie create2.php but its showing Undefined index for all the name attributes. Everything seems to be all right. I dont know why its having?

my Create2.php code

$name = $_POST['name'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$company = $_POST['company'];

$sql = "INSERT INTO users (name,mobile,email,company,document)
VALUES ('$name','$mobile','$email','$company','$document')";
mysqli_query($con,$sql);

I checked the $_POST[] on create2.php with isset(), and its not set! No values are received? Whats wrong with the code?

Zhrez Pain
  • 327
  • 1
  • 2
  • 10

2 Answers2

1

When you disable a field it does not submit the data through the form.

Try readonly instead of disabled: What's the difference between disabled="disabled" and readonly="readonly" for HTML form input fields?

Bing
  • 3,071
  • 6
  • 42
  • 81
-1

change "disabled", maybe "require", if you need that element is require the property that you need. Your form not sent noting becouse your elements are disabled

CMDR
  • 31
  • 2