Putting Username in HTML & PHP after logging in....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
latoyale
Forum Commoner
Posts: 25
Joined: Fri Apr 04, 2008 1:16 am

Putting Username in HTML & PHP after logging in....

Post by latoyale »

Good day,

I have a form. After a user logs in correctly, I want a welcome "username" to come up. How can I get this done if my page uses HTML and PHP? Unfortunately most of the tutorials I've seen online use only php to get this done. My code is:

<?php
session_start();
if(!session_is_registered(myusername)){
header("location:index.html");
}
$username = $_POST["username"];
// Check if session is not registered , redirect back to main page.
// Put this code in first line of web page.

?>
<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Ask Slicky</title>

<link href="images/styler.css" rel="stylesheet" type="text/css">

<script type="text/javascript">

<!--

function MM_openBrWindow(theURL,winName,features) { //v2.0

window.open(theURL,winName,features);

}

//-->

</script>

<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>

<body><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3668065-4";
urchinTracker();
</script>

<br>

Welcome "$myusername",<br>

<strong>Please Enter Your Description
:</strong><br>

</body>

</html>
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Putting Username in HTML & PHP after logging in....

Post by markusn00b »

Use an echo statement (you can use them wherever you need to inside html).

Code: Select all

 
<h1><?php echo "hello $username";?></h1>
 
Post Reply