Jump to content

Recommended Posts

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();



?>

Link to comment
https://forums.phpfreaks.com/topic/142420-solved-external-css-in-php/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.