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
  • 26,730
  • 9
  • 86
  • 103

3 Answers3

1

Try this

if(isset($_POST['satuan'])){
    $satuan = $_POST['satuan'];
} else{
    $satuan = '';
}
Bartłomiej Semańczyk
  • 56,735
  • 45
  • 213
  • 327
Tal
  • 869
  • 13
  • 21
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
  • 31,770
  • 15
  • 58
  • 79
0

You can try something like this..

$satuan  = (isset($_POST['satuan']) ? $_POST['satuan'] : null);
tarzanbappa
  • 4,781
  • 15
  • 70
  • 107