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?
1 Odpowiedź
+ 1
you can use the error control operator "@" like that:
<?php
echo @$_POST['title'];
?>