+ 1

HELP

<input type='text' name='k' size ='50' value='<?php echo $_GET['k']; ?>'/> ( ! ) Notice: Undefined index: k in C:\wamp\www\project\index.php on line 12 how to fix this?

18th Apr 2017, 9:49 AM
DragonSlayer
DragonSlayer - avatar
3 Answers
+ 1
if(isset($_GET['K'])) echo $_GET['K']; Good luck 😁
23rd Apr 2017, 6:42 PM
Elghozi Nasreddine
Elghozi Nasreddine - avatar
+ 10
OMG HELP HIM HE IS IN DANGER
18th Apr 2017, 9:55 AM
Ahri Fox
Ahri Fox - avatar
+ 6
Try this: <?php if( isset($_GET['k']) && !empty( $_GET['k'] ) ){ echo $_GET['k'];} ?> This way, if k parameter is not mentioned in your url, the input's value will be empty otherwise it'll take the value of ?k=something. optionally, use echo htmlspecialchars($_GET['k']); for extra security.
18th Apr 2017, 10:11 AM
CHMD
CHMD - avatar