0

is there a way to avoid "undefined index" error? (refer the code on description)

<form method="post"> <input type="text" name="title" /> <br /> <input type="text" name="link" /> <br /> <input type="text" name="content" /> <br /> <input type="text" name="hashtags" /> <br /> <button type="submit" name="submit">Submit</button> </form> <?php echo $_POST['title']; ?> // to run the code without "undefined index error" i used if statement if (!isset($_POST['title']) { echo null; } else { echo $_POST['title']; } // is there a better way to do this?

16th Oct 2018, 3:59 PM
Yohanna Wilbertson
Yohanna Wilbertson - avatar
1 Odpowiedź
+ 1
you can use the error control operator "@" like that: <?php echo @$_POST['title']; ?>
16th Oct 2018, 5:06 PM
MO ELomari
MO ELomari - avatar