Jump to content

problems in php


Porkie

Recommended Posts

hi, i have two different problems with some code i have created,

 

Firstly i have a profile page, which i need to ask for a login before it loads up.i know that i can just do require(' '); however both my profile page and login page have a header so it just messes up is there someone off just having the login boxes on my page?

 

Secondly i have this piece of code,

<?php
if ($stuff['type'] == 'Administrator'){
echo '<div id="rightcol">';
echo '<div id="centeralign">';
echo '<div id="style1">';
echo 'Admin Control Panel';
echo '</div>';
echo '<br></br>';
echo '<div id="style3">';
echo '<a href="password_protected.php">Add/Edit/Delete RSS Feeds</a><br></br>';
echo '<a href="admin.php">Main Site Admin<br></br></a>';
echo '<div id="centeralign">';
echo '<SCRIPT type="text/javascript" language="JavaScript" src="http://xslt.alexa.com/site_stats/js/t/a?url=www.source1.co.uk"></SCRIPT>';
echo '<SCRIPT type="text/javascript" language="JavaScript" src="http://xslt.alexa.com/site_stats/js/s/a?url=www.source1.co.uk"></SCRIPT>';
echo '</div>';
}
?>
<?php
echo '<div id="footer">';
echo page_footer();
?>

however my code goes directly under the rightcolumn and not in the middle of the page, how can i edit that ?

 

cheers alot :D

Link to comment
https://forums.phpfreaks.com/topic/173174-problems-in-php/
Share on other sites

hi, i have two different problems with some code i have created,

 

Firstly i have a profile page, which i need to ask for a login before it loads up.i know that i can just do require(' '); however both my profile page and login page have a header so it just messes up is there someone off just having the login boxes on my page?

 

Secondly i have this piece of code,

<?php
if ($stuff['type'] == 'Administrator'){
echo '<div id="rightcol">';
echo '<div id="centeralign">';
echo '<div id="style1">';
echo 'Admin Control Panel';
echo '</div>';
echo '<br></br>';
echo '<div id="style3">';
echo '<a href="password_protected.php">Add/Edit/Delete RSS Feeds</a><br></br>';
echo '<a href="admin.php">Main Site Admin<br></br></a>';
echo '<div id="centeralign">';
echo '<SCRIPT type="text/javascript" language="JavaScript" src="http://xslt.alexa.com/site_stats/js/t/a?url=www.source1.co.uk"></SCRIPT>';
echo '<SCRIPT type="text/javascript" language="JavaScript" src="http://xslt.alexa.com/site_stats/js/s/a?url=www.source1.co.uk"></SCRIPT>';
echo '</div>';
}
?>
<?php
echo '<div id="footer">';
echo page_footer();
?>

however my code goes directly under the rightcolumn and not in the middle of the page, how can i edit that ?

 

cheers alot :D

 

I guess that your problem is there is no style sheet telling it where to move the code. From what i can tell this is more of a css problem than in php.

 

And there was no need for all those echo's. You could have closed off php using the end tags after the if statement and just wrote in plain html and then reopened after the html but i guess it does the same job.

Link to comment
https://forums.phpfreaks.com/topic/173174-problems-in-php/#findComment-912815
Share on other sites

Try either of the two methods instead for your html:

 

Method 1: Outputting plain html

<?php
if ($stuff['type'] == 'Administrator'){
?>

<div id="rightcol">
<div id="centeralign">
<div id="style1">
Admin Control Panel
</div>
<br></br>
<div id="style3">
<a href="password_protected.php">Add/Edit/Delete RSS Feeds</a><br></br>
<a href="admin.php">Main Site Admin<br></br></a>
<div id="centeralign">
<SCRIPT type="text/javascript" language="JavaScript" src="http://xslt.alexa.com/site_stats/js/t/a?url=www.source1.co.uk"></SCRIPT>
<SCRIPT type="text/javascript" language="JavaScript" src="http://xslt.alexa.com/site_stats/js/s/a?url=www.source1.co.uk"></SCRIPT>
</div>

<?php
}
echo '<div id="footer">';
echo page_footer();
?>

 

OR, saving it inside a variable to echo out:

 

<?php
if ($stuff['type'] == 'Administrator'){
$content_holder = <<<HOLDER
<div id="rightcol">
<div id="centeralign">
<div id="style1">
Admin Control Panel
</div>
<br></br>
<div id="style3">
<a href="password_protected.php">Add/Edit/Delete RSS Feeds</a><br></br>
<a href="admin.php">Main Site Admin<br></br></a>
<div id="centeralign">
<SCRIPT type="text/javascript" language="JavaScript" src="http://xslt.alexa.com/site_stats/js/t/a?url=www.source1.co.uk"></SCRIPT>
<SCRIPT type="text/javascript" language="JavaScript" src="http://xslt.alexa.com/site_stats/js/s/a?url=www.source1.co.uk"></SCRIPT>
</div>
HOLDER;

echo $content_holder;
}

echo '<div id="footer">';
echo page_footer();
?>

Link to comment
https://forums.phpfreaks.com/topic/173174-problems-in-php/#findComment-912832
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.