|
|
#1 |
|
New Member
![]() Join Date: Feb 2012
Posts: 2
|
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 !!
|
|
|
|
|
|
#2 |
|
Gold Member
![]() Join Date: Oct 2008
Location: Ireland
Posts: 349
|
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 |
|
|
|
|
|
#3 |
|
New Member
![]() Join Date: Feb 2012
Posts: 2
|
Thanks for your reply !!!
I would prefer to keep my html and php separated...Is this possible??? |
|
|
|
|
|
#4 |
|
Gold Member
![]() Join Date: Oct 2008
Location: Ireland
Posts: 349
|
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>';
__________________
Conor |
|
|
|
|
|
#5 |
|
New Member
![]() Join Date: Mar 2012
Posts: 4
|
Make template files and use php to show the variables content.
Code:
<h2><?=$title?></h2>
__________________
MWD Web Design |
|
|
|
|
|
#6 |
|
New Member
![]() Join Date: Mar 2012
Posts: 5
|
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. |
|
|
|
|
|
#7 |
|
Bronze Member
![]() Join Date: Mar 2012
Location: Dorset
Posts: 47
|
Have a redirection page from 'you have successfully logged in' to 'members area'
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|