473,387 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PHP inline execution in HTML

I have an index.php which has at the last line the following:
[PHP]include_once("A.php");[/PHP]

I have the following in the A.php file.
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. echo $HTML_HEAD . $PRE_CONTENTS;
  3. ?>
  4. <div id="content">
  5.             <table width="460" border="0" cellspacing="0" cellpadding="0">
  6.                 ... some table infos here ...
  7.             </table>
  8. <?php if (!isset($_GET['cf'])) { ?>
  9.     <form name="contact_form" method="post" action="?<?php echo (HREF_GET) ; ?>">
  10.         <input name="Fname" type="text" value="" size="30" maxlength="60">
  11.         <input name="PrimaryNo" type="text" value="" size="29" maxlength="15">
  12.         <input name="mobileNo" type="text" value="" size="30" maxlength="15">
  13.         <textarea name="comments" cols="22" rows="4"></textarea>
  14.         <input name="EAdd" type="text" value="" size="30" maxlength="80">
  15.         <input type="submit" name="SubmitCF" value="Contact me please">
  16.     </form>
  17. </div>
  18. <?php
  19. } else {
  20. ?>
  21. Thank you for submitting you request. We'll be in touch shortly.
  22. </div>
  23. <?php
  24. }
  25. echo $POST_CONTENTS . $HTML_FOOT; 
  26. ?>
  27.  
In A.php the first and last set of PHP instructions, i.e.,
[PHP]
echo $HTML_HEAD . $PRE_CONTENTS;
[/PHP]
&
[PHP]
echo $POST_CONTENTS . $HTML_FOOT;
[/PHP] are well parsed. but the rest of them are not.

Testing it in a localserver I have the following $_SERVER array with the following values after submitting the form.
Expand|Select|Wrap|Line Numbers
  1. Array
  2. (
  3.     [HTTP_ACCEPT] => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
  4.     [HTTP_REFERER] => http://localhost/qhs/?ni=2.
  5.     [HTTP_ACCEPT_LANGUAGE] => en-gb
  6.     [CONTENT_TYPE] => application/x-www-form-urlencoded
  7.     [HTTP_ACCEPT_ENCODING] => gzip, deflate
  8.     [HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Mozilla/4.0(Compatible Mozilla/4.0(Compatible-EmbeddedWB 14.59 http://bsalsa.com/ EmbeddedWB- 14.59  from: http://bsalsa.com/ ; .NET CLR 1.1.4322)
  9.     [HTTP_HOST] => localhost
  10.     [CONTENT_LENGTH] => 70
  11.     [HTTP_CONNECTION] => Keep-Alive
  12.     [HTTP_CACHE_CONTROL] => no-cache
  13.     [PATH] => C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;;C:\www\openssl\bin;C:\www\Apache22\bin;C:\www\php5;C:\www\mysql5\bin;C:\www\perl\bin
  14.     [SystemRoot] => C:\WINDOWS
  15.     [COMSPEC] => C:\WINDOWS\system32\cmd.exe
  16.     [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
  17.     [WINDIR] => C:\WINDOWS
  18.     [SERVER_SIGNATURE] => 
  19.     [SERVER_SOFTWARE] => Apache/2.2.4 (Win32) PHP/5.2.2
  20.     [SERVER_NAME] => localhost
  21.     [SERVER_ADDR] => 127.0.0.1
  22.     [SERVER_PORT] => 80
  23.     [REMOTE_ADDR] => 127.0.0.1
  24.     [DOCUMENT_ROOT] => D:/WEBDEV/wamp/www
  25.     [SERVER_ADMIN] => webmaster@localhost
  26.     [SCRIPT_FILENAME] => D:/WEBDEV/wamp/www/qhs/index.php
  27.     [REMOTE_PORT] => 1073
  28.     [GATEWAY_INTERFACE] => CGI/1.1
  29.     [SERVER_PROTOCOL] => HTTP/1.1
  30.     [REQUEST_METHOD] => POST
  31.     [QUERY_STRING] => 
  32.     [REQUEST_URI] => /qhs/?
  33.     [SCRIPT_NAME] => /qhs/index.php
  34.     [PHP_SELF] => /qhs/index.php
  35.     [REQUEST_TIME] => 1181157014
  36.     [argv] => Array
  37.         (
  38.             [0] => 
  39.         )
  40.  
  41.     [argc] => 1
  42. )
  43.  
Similarly, after submission on the address bar I get the following:
Expand|Select|Wrap|Line Numbers
  1. http://localhost/qhs/?<?php%20echo%20(HREF_GET)%20;%20?>
I defined the following too that you may find in the codelet above:
HREF_GET <-- this one holds the $_GET values before submitting the form, which I intend to send back again to retain the present status of the site.
$_GET['cf'] <-- is a variable that is set for 'forbidding' the form to display anymore. This is set once the form is submitted.

But none of them seem to listen to my feeble instructions.

Please ask if anymore infos are needed to help me out.

I'd really appreciate if somebody points me to a good direction to solve it.

Thanks in advance.
Jun 6 '07 #1
6 3150
epots9
1,351 Expert 1GB
does it run once and break when u click submit? or does it not run at all?
Jun 6 '07 #2
pbmods
5,821 Expert 4TB
Heya, smnuman. Welcome to TSDN!

include acts a little oddly unless the file you include:
  • Has no PHP code in it whatsoever, or...
  • Is only comprised of PHP code.

The file you're including contains text both inside and outside of PHP tags, so you're going to hit a bunch of problems.

My recommendation would be to alter your include file to only contain PHP code (i.e., use a bunch of echo or print statements).
Jun 6 '07 #3
does it run once and break when u click submit? or does it not run at all?
It doesn't break, but doesn't pass my values as it should have. I am just guessing it is not escaping HTML properly.Or the HTML is not escaping PHP properly. FYI, it is a .php file though.
Jun 6 '07 #4
Heya, smnuman. Welcome to TSDN!

include acts a little oddly unless the file you include:
  • Has no PHP code in it whatsoever, or...
  • Is only comprised of PHP code.

The file you're including contains text both inside and outside of PHP tags, so you're going to hit a bunch of problems.

My recommendation would be to alter your include file to only contain PHP code (i.e., use a bunch of echo or print statements).
Hi, pbmods, thanks for the warm welcome!

Regarding the alternative, I am not sure that is a path i can walk in. 'Cos I got a number of pages(100+) and some more are team fed. My system of content management must work with these intricacies in, unfortunately or may be fortunately :( :P

Thanks anyway for the help. But I think I'll need more of it now.
Jun 6 '07 #5
pbmods
5,821 Expert 4TB
There is a method at the bottom of the PHP manual page that might do it.
Jun 7 '07 #6
There is a method at the bottom of the PHP manual page that might do it.
@pbmods
Gee, thanks for everything. Yes I have tried that <I believe that you are refering to example 16.10 >. But than I had gone back to your first suggestion -- bit less work in that i guess.( That's why some are experts, others are learners:) + bit of lazyness too;) ) I just made a way to pull all those files in a string and replacing things in them like a template.

Thanks to all.
For now my problem is solved. Although I'll change it to that reference to 16.10 in future.
Jun 7 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: FLEB | last post by:
I like PHP for its excellent inline integration into standard HTML files, but I like Perl for its quick-moving syntax and simpler data-processing. To resolve this deep-seated inner turmoil (oh, the...
23
by: Mat | last post by:
<div id="container"> <div id="main"> <div id="header"> <p class="Address">123 Fake Street, </p> <p class="City">Crazy City, </p> <p class="Province">Ontario </p> <p class="PostalCode">H0H...
14
by: Chris Mantoulidis | last post by:
I am not clear with the use of the keyword inline... I believe you add it do a function when you implement the function inside the header file where the class is stored... But is that all? What...
7
by: Alvin | last post by:
Hello all, I'm curious as to your opinions on explicitly inlining function? I'm talking about functions as members of a class. For example, so class A defines a operator==() and a operator!=():...
43
by: Patrick Laurent | last post by:
Hello I have a program with many many inlined template functions It is essential for the execution speed that every (or almost every) function marked as inlined, becomes really inlined by the...
18
by: Method Man | last post by:
If I don't care about the size of my executable or compile time, is there any reason why I wouldn't want to inline every function in my code to make the program run more efficient?
23
by: Shane Hathaway | last post by:
Here's a heretical idea. I'd like a way to import modules at the point where I need the functionality, rather than remember to import ahead of time. This might eliminate a step in my coding...
5
by: chinu | last post by:
hi all, i did a small experiment to check the effect of inline as a function. program is like this. inline int fun(); int main(){ unsigned int start=0,end=0; asm("rdtsc\t\n""mov %%eax,...
1
by: shardul316 | last post by:
FOOD FOR THOUGHT: by using inline function in c++ program we can increase th speed of execution of prog/function.as keyword inline replaces the function call by function code. if this is true...
17
by: Juha Nieminen | last post by:
As we know, the keyword "inline" is a bit misleading because its meaning has changed in practice. In most modern compilers it has completely lost its meaning of "a hint for the compiler to inline...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.