Solved

php in html

Posted on 2004-08-23
14
350 Views
Last Modified: 2010-04-06
i have a quote php script that generates random quotes (the file is quote.php) . I want the quote to be in my main page(index.htm) ..that is i want to display the quote.php( which contains a single radomly generated code) in my home page in a corner.

Thanks
0
Comment
Question by:intercodes
  • 5
  • 3
  • 3
  • +3
14 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 50 total points
ID: 11872039
Hi

Change index.htm to index.php and then use <?php include("quote.php"); ?> in that corner. Best way I knwo of.

Regards,
Zyloch
0
 
LVL 15

Expert Comment

by:joeposter649
ID: 11872267
0
 
LVL 10

Expert Comment

by:rockmansattic
ID: 11874769
you could also use javascript for this..

0
 
LVL 11

Expert Comment

by:neester
ID: 11877131
Firstly - Strongly advise against an IFrame.

If anything use Zylochs comment.
Much better.
0
 
LVL 15

Expert Comment

by:joeposter649
ID: 11877446
Seems like the perfect place to use an iframe to me if they want to keep index.htm.
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11877538
An iframe would work in the situation, but if you have a quote.php page, I'm assuming you have PHP on your server so...
0
 
LVL 11

Expert Comment

by:neester
ID: 11877717
The problem is, how can he include the quote on the page with an iframe...
the iframe will take up a block of room - there is no need at al.

if the server can compile PHP for the quotes.php file - the BEST possible solution would be to make the index file a PHP file.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:intercodes
ID: 11881211
So changing my index.htm to index.php doesnt affect my present contents in index.htm. i mean it is witten in HTMl and contains lot's of stuff..those stuff wud be intact if i change my index to php extension?
0
 
LVL 15

Expert Comment

by:joeposter649
ID: 11881276
It shouldn't.  
http://www.w3schools.com/php/php_syntax.asp

But your site will be affected if you have links in your site to index.htm or if a user has bookmarked it.
0
 
LVL 11

Expert Comment

by:neester
ID: 11881621
Intercodes:

No the .php will only mean that the PHP compiler will run through the page.

It ignored everything that isn't included inside the <?PHP ?> tags.
So anything else is just sent to the browser like normal.

So if you just have this in your page:

<?php include("quote.php"); ?> -or-
<?php include_once("quote.php"); ?> - that will stop any problems if yuo have any sort of recurring page load etc...
Not really too applicable here...

What JOEPOSTER said is true.



----------------

BUT

You can fix that simply by, creating a file called: .htaccess
inside the .htaccess file have this code:

ReWriteEngine On
ReWriteRule ^index.html$ index.php


That will allow you to run the PHP with the HTML file...
0
 
LVL 11

Expert Comment

by:neester
ID: 11881647
To Sum It All up...



1] RENAME THE FILE TO, index.php
2] INSERT THIS CODE TO INCLUDE THE QUOTES: <?php include("quote.php"); ?>
3] CREATE FILE CALLED: .htaccess - INSIDE THE MAIN FOLDER OF THE WEBSITE
4] ADD THIS CODE TO THE .htaccess FILE:
          ReWriteEngine On
          ReWriteRule ^index.html$ index.php
5] UPLOAD AND ITS ALL DONE!

You can navigate to: www.yoursite.com/index.html
and the server will simply load the index.php file!!
But to the user, it will appear to just be the HTML file :)
easy done...
No need to change links anywhere.
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11882523
To make sure other sites can still go to index.html, you can use mod_rewrite like neester said (which would only work on Apache servers), or you can set your server to accept .html files as PHP in your httpd.conf file (if Apache).
0
 
LVL 1

Expert Comment

by:pjargon
ID: 11892402
um.  you might want to check if you have a .htaccess file already, and edit that one.
0
 
LVL 11

Expert Comment

by:neester
ID: 11892615
True PJargon,
You woudlnt want to overwrite any current htaccess directives
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to extract window origin in spring 2 65
CSS HELP 6 84
Questions about this React unit test 4 46
Download a website to hdd 2 52
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now