After I login the user, I want to have a separate html page (a front page) that says "welcome, (user)." I tried to use cookies and I now know this wont work. So how would i go about doing this?
Here is my code (in my sigin script):
header('Location: frontpage.html');
In frontpage.html, I want to use some of the data from the sigin script.
This is controlled by the $_SESSION array. When your user logs in, you should set some $_SESSION variables to whatever values you want (say, one variable which will let you know the user is logged in, another with their user name, another with their permissions, etc.).
Then just echo the $_SESSION variable with the relevant user name to the user:
echo 'Welcome, ' . $_SESSION['username'] . '.';
The PHP manual has extensive information on sessions: http://il2.php.net/manual/en/intro.session.php
use php echo inside your code http://ca.php.net/manual/en/function.echo.php
but if you want this to work as you say, use templating engine. I suggest Smarty
I would def not use cookies to save user credentials as this can be ripped from your browser with an inject script or harmful site. Look into PHP Sessions to achieve user log ins.
In terms of serving html to a client browser that is very easy. You could load the html page with PHP and echo it to the browser. Since PHP is a server side language this script output is produced before being sent to the client. The html would be rendered into the browsers DOM and you are done.
But I would suggest using an MVC framework like CodeIgniter or I have created a very simple un-bloated MVC called PHPBlueprint that would work (and be very easy to configure). This will allow you flexibility and abstractions between your coding logic.
UPDATE
This would be myPage.php
<?php
$myVar = 3;
echo "<html>
<head>
<title>My Page</title>
</head>
<body>
$myVar
</body>
</html>";
?>
or you could do:
<html>
<head>
<title>My Page</title>
</head>
<body>
<?php
$myVar = 3;
echo $myVar;
?>
</body>
</html>
Either way you choose to do this the script will be run on the server and then send the data to a client browser as:
<html>
<head>
<title>My Page</title>
</head>
<body>
3
</body>
</html>
The HTML will be rendered into the DOM and the page should look display:
3
PHP is very much worth the time to learn, as is MVC as it promotes great OOP and expandable solutions for rapid development. Look at PHPBlueprint as this will simplify all of these and will be easy to reverse engineer.