I’m trying to create a quick and dirty simple menu that is generated by PHP.The function logScreen() determines whether a user has logged in, and if not then generate a prompt for the user to login.
However the output from this ( the generated input tags that would allow the user to fill in their information) is generated outside of the table instead of inside of the td tags where it is placed.
Does anybody have any suggestions to get the output of this command into the table where I have it placed. If anybody could help I would appreciate it. Thanks
<html>
<head></head>
<body>
<?php
include ('functions.php');
function loggScreen()
{
if(!isset($_SESSION['user']))
{
echo "<td>";
echo "User Name: <input value='Username'>";
echo "Password : <input value='Password'>";
echo "<input type='button' value='login'>";
echo "</td>";
}
}
echo "<table border=1 style='width:100%;'>";
echo "<tr><td style='width:80%;'>Welcome to the website</td>".loggScreen()."</tr>";
echo "</table>";
?>
</body>
</html>
Unless you’re using output buffering, echo will
outputtostdoutas soon as it’s called. Instead ofechoing in your logging function, you want toreturna string: