Web Design Forum  
 
Go Back   Web Design Forum > Web Software > Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 02-04-2012, 10:27 PM   #1
New Member
 
Join Date: Feb 2012
Posts: 2
Default PHP Newbie

Hey all !!

I'm new here and new to programming in general...

I have been dabbling in PHP recently and I'm really starting to enjoy it. I do however have one question which may be a bit stupid but here goes anyway...

If I write a PHP programme that allows somebody to login to my website, I don't necessarily want to echo a plain white page when the person logs in successfully..What is the most efficient way of echoing an entire page...?? I tried it earlier but I found it very messy when mixing php and html...Is there some alternative way that I don't know about.??

Cheers !!
anderson is offline   Reply With Quote


Old 02-04-2012, 11:10 PM   #2
Gold Member
 
conor's Avatar
 
Join Date: Oct 2008
Location: Ireland
Posts: 349
Default

you could just close the php tag when you want to echo html, like this:

Code:
<?php
 // do some php here
?>
<!-- have some html here -->
<?php
 // some more php
?>
__________________
Conor
conor is offline   Reply With Quote
Old 02-04-2012, 11:36 PM   #3
New Member
 
Join Date: Feb 2012
Posts: 2
Default

Thanks for your reply !!!

I would prefer to keep my html and php separated...Is this possible???
anderson is offline   Reply With Quote
Old 02-05-2012, 09:09 AM   #4
Gold Member
 
conor's Avatar
 
Join Date: Oct 2008
Location: Ireland
Posts: 349
Default

Yes it is possible, but as you said it can look kind of messy some times. You can do stuff like this:

Code:
echo '<html>

<body>
<div/>
</body>';
echo '</html>';
or you could look into some kind of templating system that aims to seperate html and php such as the Smarty Template Engine http://www.smarty.net/
__________________
Conor
conor is offline   Reply With Quote
Old 03-17-2012, 05:22 PM   #5
New Member
 
Join Date: Mar 2012
Posts: 4
Default

Make template files and use php to show the variables content.

Code:
<h2><?=$title?></h2>
While smarty allows to separate look from logic, it does a double process reconverting the template language to php.
__________________
MWD Web Design
Thomas is offline   Reply With Quote


Old 03-26-2012, 05:11 AM   #6
New Member
 
Join Date: Mar 2012
Posts: 5
Default

You can also, rather than echoing the page itself you could simply add a redirect into your code that sends them to your main page after they have logged in using:

header('Location: http://www.example.com/');

of course you can't call the header function to redirect if input has already been loaded to the page I believe unless you use the "ob_start()" function.

Please someone correct me if I'm wrong.
Nifty62 is offline   Reply With Quote
Old 03-30-2012, 09:57 PM   #7
Bronze Member
 
Nathan Joshua's Avatar
 
Join Date: Mar 2012
Location: Dorset
Posts: 47
Default

Have a redirection page from 'you have successfully logged in' to 'members area'
__________________
Quality > Quantity
Mattress reviews | Web design dorset |
Web design articles
Nathan Joshua is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:15 PM.


Camera Forum - Computer Forum - Web Design Forum

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.