jimbo_3000 Posted January 26, 2009 Share Posted January 26, 2009 OK, the inline css is working fine. However; when I attempt to make the inline css into an external css page it does not work. My question is How do I add the external css properly? here is the code with inline css <?php require_once('requires.php'); require_once('Photos.php'); class CreateAccountPage extends PhotoShareBase { public function __construct() { parent::__construct(); } public function title() { return 'Create Account'; } public function inlineStyle() { $style = <<<EOSTYLE label { margin-top: 0.5em; display: block; font-family: Arial, Helvetica; font-size: 10pt; color: #444; /* Name of forms */ } EOSTYLE; return parent::inlineStyle() . $style; } protected function generateBodyContents() { parent::generateBodyContents(); if (User::amILoggedIn()) { echo 'Sorry, you can\'t be logged in when viewing this page'; return; } echo <<<EOCONTENTS <h3>Create a New User Account</h3> <form method='post' action='SubmitAccountData.php' name='create_user_form'> <div> <label>User Name:</label> <input type='text' name='user_name' size='30'> </div> <div> <label>Full Name:</label> <input type='text' name='full_name' size='30'> </div> <div> <label>Password:</label> <input type='password' name='password1' size='20'> </div> <div> <label>Password (confirm):</label> <input type='password' name='password2' size='20'> </div> <div> <label>Email Address:</label> <input type='text' name='email_address' size='30'> </div> <div> <label>User Bio:</label> <textarea name='user_bio' rows='10' cols='40'></textarea> </div> <p><input type='submit' value='Create User'></p> </form> EOCONTENTS; } } $page = new CreateAccountPage(); $page->processRequest(); ?> And here is the code when I made the external link. <?php require_once('requires.php'); require_once('Photos.php'); class CreateAccountPage extends PhotoShareBase { public function __construct() { parent::__construct(); } public function title() { return 'Create Account'; } public function inlineStyle() { $style = <<<EOSTYLE <link rel='stylesheet' type='text/css' href='mystyle.css'> EOSTYLE; return parent::inlineStyle() . $style; } protected function generateBodyContents() { parent::generateBodyContents(); if (User::amILoggedIn()) { echo 'Sorry, you can\'t be logged in when viewing this page'; return; } echo <<<EOCONTENTS <h3>Create a New User Account</h3> <form method='post' action='SubmitAccountData.php' name='create_user_form'> <div> <label>User Name:</label> <input type='text' name='user_name' size='30'> </div> <div> <label>Full Name:</label> <input type='text' name='full_name' size='30'> </div> <div> <label>Password:</label> <input type='password' name='password1' size='20'> </div> <div> <label>Password (confirm):</label> <input type='password' name='password2' size='20'> </div> <div> <label>Email Address:</label> <input type='text' name='email_address' size='30'> </div> <div> <label>User Bio:</label> <textarea name='user_bio' rows='10' cols='40'></textarea> </div> <p><input type='submit' value='Create User'></p> </form> EOCONTENTS; } } $page = new CreateAccountPage(); $page->processRequest(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/142420-solved-external-css-in-php/ Share on other sites More sharing options...
premiso Posted January 26, 2009 Share Posted January 26, 2009 The looks right to me, although the link may have to be in the header, not sure. I would print out the source of the created HTML page and see if anything looks funky there. Quote Link to comment https://forums.phpfreaks.com/topic/142420-solved-external-css-in-php/#findComment-746189 Share on other sites More sharing options...
jimbo_3000 Posted January 26, 2009 Author Share Posted January 26, 2009 here is the other code i am not sure if this is right? <?php require_once('Request.php'); abstract class VisualPageBase extends RequestHandler { public function __construct() { } public abstract function title(); protected abstract function generateBodyContents(); public function inlineStyle() { return ''; } public function processRequest() { // make sure we process any incoming POST data as appropriate parent::processRequest(); /** * Now emit page contents */ $titleText = $this->title(); $inlineStyle = $this->inlineStyle(); $this->emitHeaders($titleText, $inlineStyle); echo "<body>\n\n"; $this->generateBodyContents(); echo "</body>\n\n"; echo "</html>\n\n"; } protected function emitHeaders($titleText, $inlineStyle) { echo <<<EOHEADERS <html> <head> <title>{$titleText}</title> <style type='text/css' media='all'> body { font-family: Arial, Helvetica; } {$inlineStyle} </style> </head> EOHEADERS; } } ?> I know i can change the <style type='text/css' media='all'> to match this <link rel='stylesheet' type='text/css' href='mystyle.css'> but i am not sure how to change the rest of it. Quote Link to comment https://forums.phpfreaks.com/topic/142420-solved-external-css-in-php/#findComment-746212 Share on other sites More sharing options...
premiso Posted January 26, 2009 Share Posted January 26, 2009 I meant view the source of the php created page and look at how it is coming up. It may be the fact that mystyle.css is not where the site is trying to find it, maybe try and define an absolute path to it. Quote Link to comment https://forums.phpfreaks.com/topic/142420-solved-external-css-in-php/#findComment-746214 Share on other sites More sharing options...
jimbo_3000 Posted January 30, 2009 Author Share Posted January 30, 2009 you were right the css was just referring to a wrong css file. Quote Link to comment https://forums.phpfreaks.com/topic/142420-solved-external-css-in-php/#findComment-750799 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.