I have a below code which has a input text box and its value I want to set is php variable. Below is the code:
index.php
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<link href="main.css" rel="stylesheet" type="text/css" href="" />
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="512000" />
Select file: <input name="userfile" type="file"/>
<input type="text" name="filename" value=<?php echo $filename; ?> />
<input type="submit" value="Send File" multiple/>
</form>
</body>
</html>
Now the above code is working fine and it does what is written in upload.php. But for some reason, inside the input type text box, there is <br in it. I am not able to make it clear. Also it says undefined variable filename. Below is the screenshot of the webpage:
Can anyone please help in why it says filename undefined variable and why <br is shown on input type text box. I have tried below approach but nothing worked:
<input type="text" name="filename" value="<?php echo $filename; ?>" />
<input type="text" name="filename" value='<?php echo $filename; ?>' />


$filename = "";but doesnt worked.