Help - Search - Members - Calendar
Full Version: How to get rid of viewing source code?
HTMLHelp Forums > Programming > Server-side Scripting
Arjun Dey
I have recently hosted a website & I am able to see a part of my source code on one of the pages.

Here's the link : http://www.taipanleather.com/enquiry.html

I have used the same coding standard for all the pages and everyother page on my website is working fine, except this page.

Please help me to fix this.
pandy
Looks like the PHP isn't parsed. Have you set the server up to parse html pages?
Arjun Dey
QUOTE(pandy @ May 3 2014, 02:28 AM) *

Looks like the PHP isn't parsed. Have you set the server up to parse html pages?


Yes, this is the content of my .htaccess file :

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

FYI, I have hosted on a linux server & hence, no web.config file in my server directory.
Christian J
Do you use PHP on the other pages, e.g. http://www.taipanleather.com/leather-products.html ? If so I have no idea what makes it show on the first page.

I recall seeing some web host where you couldn't use AddType for enabling PHP in .html extension files, but then it affected all pages.

What happens if you rename "enquiry.html" to "enquiry.php"?
jimlongo
missing <?php tags or maybe using short tags <? but not allowed in php.ini
pandy
The tags that are displayed aren't short tags though.
Arjun Dey
QUOTE(Christian J @ May 3 2014, 05:19 PM) *

Do you use PHP on the other pages, e.g. http://www.taipanleather.com/leather-products.html ? If so I have no idea what makes it show on the first page.

I recall seeing some web host where you couldn't use AddType for enabling PHP in .html extension files, but then it affected all pages.

What happens if you rename "enquiry.html" to "enquiry.php"?


No, no other page refers to a php code. All are in html.
The enquiry.html file is a html code too, but it calls a php source (email.php) to send out the email after filling that form.

Tried renaming to enquiry.php & hosted it, but it still doesn't work! Says "webpage not found".

QUOTE(jimlongo @ May 3 2014, 07:03 PM) *

missing <?php tags or maybe using short tags <? but not allowed in php.ini

Checked my code thoroughly and found no missing tags.

Will sharing the source code files here help you to identify the problem?
Christian J
QUOTE(Arjun Dey @ May 4 2014, 08:03 PM) *

Tried renaming to enquiry.php & hosted it, but it still doesn't work! Says "webpage not found".

You must have uploaded the new version to another directory, at least it's not here: http://www.taipanleather.com/enquiry.php

You can also test PHP support by creating a file like "test.php", which just contains this:

CODE
<?php phpinfo(); ?>

--if PHP is supported it will produce a table listing various configurations, etc.

QUOTE
Will sharing the source code files here help you to identify the problem?

Most likely the problem is how to make the server run PHP at all. Try the tests above again.

Arjun Dey
QUOTE(Christian J @ May 4 2014, 11:46 PM) *

You must have uploaded the new version to another directory, at least it's not here: http://www.taipanleather.com/enquiry.php


OK. I did a silly mistake. I uploaded enquiry.php, but didn't map it to the enquiry buttons.
However, code is vanished now. :-)
Please check : http://www.taipanleather.com/enquiry.php

Thanks for your suggestions, everyone!

Cheers!!
Christian J
QUOTE(Arjun Dey @ May 4 2014, 09:12 PM) *

However, code is vanished now. :-)

Good! Wonder why the .htaccess directive didn't work for .html files, though. The following part seems correct:

CODE
AddType application/x-httpd-php .php .htm .html

but do you really need the part above:

CODE
RemoveHandler .html .htm

? What happens if you remove it?

Arjun Dey
QUOTE(Christian J @ May 5 2014, 12:55 AM) *

CODE
RemoveHandler .html .htm

? What happens if you remove it?


Well, its basically to disable server-side parsing & to not show the script contents to visitors.

I have another problem now... The mail is not being sent to the hard-coded email ID after submitting the form.
Have been working for long on this, but to no success. Please help me to fix this.
pandy
QUOTE(Arjun Dey @ May 5 2014, 09:58 PM) *

Well, its basically to disable server-side parsing & to not show the script contents to visitors.

It disables server side parsing alright, but that would rather let visitors view the content since it's there in the source, not being parsed.

Did you really have those two directives in the same .htacess file and in the order you posted them here? Reversed order or RemoveHandler in a directory closer to the html file in question would explain what happened.
Christian J
QUOTE(Arjun Dey @ May 5 2014, 09:58 PM) *

I have another problem now... The mail is not being sent to the hard-coded email ID after submitting the form.
Have been working for long on this, but to no success. Please help me to fix this.

We'd have to see the PHP code for that (perhaps it's more practical to start a new thread in the server-side scripting forum as well).
pandy
Where this thread now resides.
Arjun Dey
QUOTE(Christian J @ May 6 2014, 02:06 AM) *

We'd have to see the PHP code for that (perhaps it's more practical to start a new thread in the server-side scripting forum as well).


Attached the 2 source code files for your perusal.
Looking forward to your suggestions on fixing this.
CharlesEF
Is your web server setup to process .html pages with php code? If you did not do this then the file enquiry.html should be changed to enquiry.php. Maybe you should try it anyway.
Arjun Dey
QUOTE(CharlesEF @ May 7 2014, 12:38 AM) *

Is your web server setup to process .html pages with php code? If you did not do this then the file enquiry.html should be changed to enquiry.php. Maybe you should try it anyway.


Oops.. My bad! I attached enquiry.html instead of attaching enquiry.php.
enquiry.php is the file which is hosted on my website now : www.taipanleather.com/enquiry.php
The code is same, the extension is different.

BTW, what to edit in the .htaccess file to allow the server to process .html pages with php code in it? Let me try this too...
Christian J
QUOTE
The mail is not being sent to the hard-coded email ID after submitting the form

I'm not familiar with class programming, how does the script access the submitted form data? Can extract() really do that?

Also, what do the mail() function arguments look like if you print them out?
Christian J
QUOTE(Arjun Dey @ May 6 2014, 09:15 PM) *

BTW, what to edit in the .htaccess file to allow the server to process .html pages with php code in it? Let me try this too...

Try removing RemoveHandler.
Arjun Dey
QUOTE(Christian J @ May 7 2014, 01:14 AM) *

Try removing RemoveHandler.

Tried it. No luck. sad.gif

Tried adding all these to my .htaccess, but no luck again. sad.gif

AddType application/x-httpd-php .php .htm .html
AddType application/x-httpd-php5 .php .htm .html
AddHandler application/x-httpd-php .htm .html
AddHandler application/x-httpd-php5 .htm .html

FYI, the server is currently running on PHP 5.2.
CharlesEF
I glanced at your code but to be honest I think your logic is wrong. Looks like your validation tests will never fire so that means to whole section is skipped. Have you tried to submit the form with information missing? I have to go out on a service call and will be gone for a few hours but I will look more when I get back.
Christian J
QUOTE(Arjun Dey @ May 6 2014, 09:59 PM) *

QUOTE(Christian J @ May 7 2014, 01:14 AM) *

Try removing RemoveHandler.

Tried it. No luck. sad.gif

Do you use other .htaccess files in directories above the web root? Or maybe your server is configured in an unusual way? The web host support should be able to help.

QUOTE
FYI, the server is currently running on PHP 5.2.

No AFAIK it's PHP running on the server --not the other way around-- and it's the server that needs to be configured to run PHP on files with .html extensions.

CharlesEF
I'm no HTML expert but I would fix the HTML before you try to fix the php. As far as I know nothing can be beyond </html> but you have elements and javascript placed there. Also, you are using 3 content-type <meta> elements, 2 in the wrong place.
Arjun Dey
Just by trial-and-error, I came to know that I have tasted half-success.

The form is working fine on Google Chrome browser, but not on IE.

What could be the issue now?
CharlesEF
The reason I suggested you fix the HTML is because, the way it is, Firefox v29 will not even submit properly. The isset($_POST['submit']) never fires.
Christian J
QUOTE(CharlesEF @ May 7 2014, 10:23 PM) *

The isset($_POST['submit']) never fires.

Good catch! It seems the image submit button is causing this. According to HTML4.01,

QUOTE
The submitted data includes name.x=x-value and name.y=y-value where "name" is the value of the name attribute, and x-value and y-value are the x and y coordinate values, respectively.

If you examine the submitted data with e.g. this:

CODE
echo '<pre>';
print_r($_POST);
echo '</pre>';

you may get the following result in Iron (Chrome) and K-Meleon 1.5.4:

CODE
Array
(
    [submit_x] => 123
    [submit_y] => 123
    [submit] => foo
)

(where the numbers are your mouse coordinates, and "foo" is the value of the submit button), but my other browsers (including Firefox 28) just produce this:

CODE
Array
(
    [submit_x] => 123
    [submit_y] => 123
)

So isset($_POST['foo']) can't be used for most browsers if you use an image submit button. Possibly you could use isset($_POST['foo_x']).

(Note that an underscore is used by the PHP engine output, even though browsers appear to submit with period signs just like the spec says.)
CharlesEF
I did think about the image being the problem (I was not sure) and I changed it to button type but Firefox would still not fire correctly. That is when I looked at the HTML and saw many problems. Anyway, glad you figured it out and I hope this helps the OP.
Arjun Dey
QUOTE(Christian J @ May 8 2014, 04:09 AM) *

So isset($_POST['foo']) can't be used for most browsers if you use an image submit button. Possibly you could use isset($_POST['foo_x']).

(Note that an underscore is used by the PHP engine output, even though browsers appear to submit with period signs just like the spec says.)


I'm not good in programming & so, I'm unsure if I understand you correctly.

Do you want me to change isset($_POST['submit'] to isset($_POST['submit_x'] in the code which I shared? Or did you mean something else?
Christian J
QUOTE(Arjun Dey @ May 8 2014, 11:24 AM) *

Do you want me to change isset($_POST['submit'] to isset($_POST['submit_x'] in the code which I shared?

Yes, either that or use a normal submit button.
Christian J
QUOTE(CharlesEF @ May 8 2014, 06:32 AM) *

I did think about the image being the problem (I was not sure) and I changed it to button type but Firefox would still not fire correctly. That is when I looked at the HTML and saw many problems. Anyway, glad you figured it out and I hope this helps the OP.

There are other problems as well, but I haven't looked closely. A few general ideas:

* Use the validator. E.g., there's no element called <no_translate>.

* It doesn't make sense to use XHTML unless you really want to be very careful with syntax and validation. Otherwise, use some more forgiving HTML version like HTML4/transitional or HTML5.

* The FONT element is very old, use CSS instead.

* Be more careful with naming element attributes, e.g. giving a submit button the ID "Reset" might confuse you later on.

* An image submit button should have ALT text for accessibility.
Arjun Dey
QUOTE(Christian J @ May 8 2014, 06:20 PM) *

Yes, either that or use a normal submit button.


Great! Changed it to submit_x and the form is working fine on IE too. Changed ID to Submit too. Thanks Christian! smile.gif
Can you please check on firefox, safari or any other browser you use and let me know if its all fine there too?

However, this brings me to another question of help & sorry to keep you waiting on this thread due to my questions.

The enquiry buttons are properly aligned on IE for this webpage : http://www.taipanleather.com/finished-leather.html
but on Google Chrome browser, the enquiry buttons shows together from the first item.

Is there a code-fix like this, which will make it to work the same way on all browsers?
This time it is intended to work on other browsers like it works on IE.
Arjun Dey
Some one please help me to fix this issue...

Also, what is the way to get a floating button on html?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.