below is my code where i am writing a code in php and calling it in body. When i run it and view source, the code gets visible. I have seen some site where nothing gets shown on source but a form appears on webpage. How can i do it too?
<?php
{ $avatar_form = '<form id="avatar_form" enctype="multipart/form-data" method="post" action="myphoto.php">';
$avatar_form .= '<h4>Change your avatar</h4>';
$avatar_form .= '<input type="file" name="avatar" required>';
$avatar_form .= '<p><input type="submit" value="Upload"></p>';
$avatar_form .= '</form>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Avatar</title>
</head>
<body>
<div><?php echo $avatar_form; ?></div>
</body>
</html>
Thanks Shail
Check whether the file type is .php or .html?
if html, it will show the php code.
If so, save it as .php
.php..htmlfile. And your web server has no idea that it needs to process it as php