Beginner's basic Joomla form question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Riverside
Forum Newbie
Posts: 7
Joined: Thu Apr 14, 2011 12:49 pm

Beginner's basic Joomla form question

Post by Riverside »

Hi, I'm a PHP hack. Don't understand the code very well, but not afraid to hack it anyway if I can.

I have a really BASIC question pertaining to the way PHP handles forms.

If a form is submitted and has either valid or invalid input, how is the page reload handled? By the form code, or externally?

I've got a contact form in Joomla. I have a specific template assigned to the form. Whenever submit is pressed, regardless of whether the form input is okay or not, the page reloads with the template assigned to the home page. I'm trying first to figure out whether it is the form code that's doing this, or some default behavior in Joomla so I know where to start looking. I want this form to always load with the same template no matter what.

Anybody?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Beginner's basic question

Post by social_experiment »

Riverside wrote:If a form is submitted and has either valid or invalid input, how is the page reload handled? By the form code, or externally?
It depends on the action of your form.

Code: Select all

<!-- will execute on itself -->
<form action="" />
<!-- will go to page.php and execute the code on there -->
<form action="page.php" />
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Riverside
Forum Newbie
Posts: 7
Joined: Thu Apr 14, 2011 12:49 pm

Re: Beginner's basic question

Post by Riverside »

Thanks Social, but that's not much help. Maybe my question wasn't specific enough. I do understand that the code that loads the page can either be anywhere the programmer wants it. Except when your code is being written to work with an existing program.

This is specifically in relation to Joomla. Keep in mind that I don't even really have a decent understanding of how the core of Joomla works. The form code is a Joomla Component addon. It's a contact form. All components in Joomla interact with Joomla code. I know that much. What I don't know is whether it is Joomla, or the addon (form) that is loading the page. I don't think it is. I think it's a Joomla action that's called by the component.

I guess what I'm really asking is how Joomla handles page loads so it's somewhat more of a Joomla question than a PHP question. I was hoping somebody here might be familiar with Joomla's inner workings.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Beginner's basic question

Post by social_experiment »

If it's a Joomla addon you can try contacting the creator, they will (hopefully) have an answer to your question. Remember to give them enough details about the problem ;)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Beginner's basic Joomla form question

Post by Christopher »

Riverside wrote:I've got a contact form in Joomla.
I changed the title of your post to reflect that this is not a basic PHP form question, but a Joomla question.
(#10850)
Riverside
Forum Newbie
Posts: 7
Joined: Thu Apr 14, 2011 12:49 pm

Re: Beginner's basic Joomla form question

Post by Riverside »

I have actually figured this out partially, though I wouldn't say I totally understand it. Turns out it's a combination betweenhow the Joomla component extension is constructed, and the template. The problem was happening in Joomla 1.5 installation. The component was not really constructed the "Joomla way." There is a default.php file that most components include that can be used to display either the component's default view or the default template view. If that file doesn't exist in the 1.5 form component, when submit is pressed the page reverts to the default template. This component didn't have that file.

Rather than mess around trying to fix it or find a different contact component, I've decided to switch over to Joomla 1.6, which has far better template and permissions control now built into the core system. Found a different contact component with spam protection that works with 1.6. The page now behaves exactly as expected.

This works for this site. There aren't many addons compatible with 1.6, but I need very few for this site anyway so this is, for now, the perfect and least troublesome solution.
Post Reply