Forums / Templates, Stylesheets, Page Layout / How can I execute PHP code in a page?

How can I execute PHP code in a page?

Locked

Started by zirconx on 6 Dec 2006, 1:50 AM · Views: 7,275

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
6 Dec 2006, 1:50 AM
#1
zirconx avatar

zirconx

New Zenner

Join Date:
Jan 2006
Posts:
6
Plugin Contributions:
0

How can I execute PHP code in a page?

I'd like to setup a custom order form for a special product. This probably won't even go through the zencart checkout system, its just a way to fill out a form and submit it.

I could just stick up a php page on my side, but I'd really like it to look like the rest of the site, with header, footer, menus, etc. So I started doing it in one of my custom pages using the page editor, but when I view the site, all my php code ( stuff between <?php and ?>) was stripped out.

How can I have a page on the site that will be executed? I've dug around these forums and various FAQs but couldn't find an answer.

Thanks!

6 Dec 2006, 2:31 AM
#2
zirconx avatar

zirconx

New Zenner

Join Date:
Jan 2006
Posts:
6
Plugin Contributions:
0

Re: How can I execute PHP code in a page?

Now that I think about it, it may be possible to just do this as a product in the cart. If I can add several custom fields that customers can fill in, and I will use a popup window to show the 15 different color images... what would be nice is if I could make a custom product page, where I could control where the 'color' drop down box shows up, so I can put a link to a popup color picker next to it, etc.

Any advice appreciated. I'm still curious on how to get zencart to execute php in a page, too.

6 Dec 2006, 3:42 AM
#3
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How can I execute PHP code in a page?

the editor will process html I know...noit sure about php entered this way. Youcould create a php file to be called and include the applicationtop in it for the same look.

A form though is normally html kinda like:

<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12" name="Fname">:<br />
Last Name:<input type="text" size="12" maxlength="36" name="Lname">:<br />
``` and then you can enter this in the editor or call it from php.

I think that Zen Cart uses js forms though

Zen-Venom Get Bitten

6 Dec 2006, 3:54 AM
#4
blindside avatar

blindside

Totally Zenned

Join Date:
Sep 2004
Posts:
1,237
Plugin Contributions:
1

Re: How can I execute PHP code in a page?

You cannot enter PHP via FCKEditor, HTMLArea, etc. as these are designed strictly to build HTML pages WYSIWYG-style. They treat everything as if it should appear on the screen exactly as you have typed it, and will strip or otherwise scrub code.

It's really not that hard to create new pages within the Zen Cart system. Take a look at the templating system. includes/templates/template_default/templates/tpl_page_2_default.php is left over form the pre-"EZ Pages" days, but it's a perfect, simple example of the what and how in building your own pages.

Speaking of EZ Pages, that could also be a possible solution. You should take a look at the documentation for it to see if you can use that.

Frank Koehl
"Cleverly Disguised as a Responsible Adult"

frankkoehl.com

6 Dec 2006, 4:01 AM
#5
zirconx avatar

zirconx

New Zenner

Join Date:
Jan 2006
Posts:
6
Plugin Contributions:
0

Re: How can I execute PHP code in a page?

I'm not using the wysiwyg editor, I'm just using the plain text area. I'm not ending up with the actual tags and code, what happens is that the php code is just gone, it seems like zencart is stripping it out.

If I do AA<?php phpinfo(); ?>BB

I just end up with AABB on the page.

And I think I might be using the EZ pages, I'm doing it through the Page Editor, which I think reads and writes files in something like the english/templates directory.

I think what I'm going to do is have a link to a popup window that has the color options, all 15 images using a roll-over, etc. in it. THen when those choices are done, use javascript to write them back to a text field in the product page.

6 Dec 2006, 4:22 AM
#6
blindside avatar

blindside

Totally Zenned

Join Date:
Sep 2004
Posts:
1,237
Plugin Contributions:
1

Re: How can I execute PHP code in a page?

Diff scenario, same result: code is scrubbed out from the define pages, as they are only expected to contain HTML.

I think what I'm going to do is have a link to a popup window that has the color options, all 15 images using a roll-over, etc. in it. THen when those choices are done, use javascript to write them back to a text field in the product page.
I think you're making this more complicated than it needs to be. Bite the bullet and teach yourself about the templating system. It'll pay dividends when it comes time to do more complex customizations or troubleshoot an upgrade/modification. Definitely speaking from experience on this one.

Frank Koehl
"Cleverly Disguised as a Responsible Adult"

frankkoehl.com

6 Dec 2006, 2:36 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: How can I execute PHP code in a page?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.