0

I'm new in PHP and I'm getting this error:

Undefinded index: satuan in D:\xampp\htdocs\Belajar\data\insertstoragedata.php on line 11

I couldn't find any solution online, so maybe someone can help me.

Here is the code:

$satuan             =   $_POST['satuan'];

thats the 11 line,can anyone help me??? I really can't understand why

Taryn East
  • 27,486
  • 9
  • 86
  • 108

3 Answers3

1

Try this

if(isset($_POST['satuan'])){
    $satuan = $_POST['satuan'];
} else{
    $satuan = '';
}
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
Tal
  • 1,091
  • 12
  • 25
0

Try some thing like this

<form action="insertstoragedata.php" method="post">
    <input type="text" name="satuan">
    <input type="submit" value="submit">
</form>

In insertstoragedata.php

$satuan = $_POST['satuan'];

Note: make sure name="" is correct. Its Case Sensitive

And possible duplicate of PHP: "Notice: Undefined variable" and "Notice: Undefined index"

Community
  • 1
  • 1
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
0

You can try something like this..

$satuan  = (isset($_POST['satuan']) ? $_POST['satuan'] : null);
tarzanbappa
  • 4,930
  • 22
  • 75
  • 117