Post a form and index.php

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
User avatar
timgerr
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 19, 2006 4:22 am
Location: Michigan

Post a form and index.php

Post by timgerr » Mon Oct 15, 2007 9:10 pm

Hey all, I have a question for you.  I haven't coded in Joomla for a long time and I am trying to get my coding fingers back.  This sould be an easy one for you.  Lets say that I want to create a form and post back to the same page like this.

Code: Select all

<body>
<form name="submitThis" id="topForm" action="<?php $mosConfig_live_site ?>/index.php?option=com_backendform" type="post">method="post">
<input type="test" id="test"></input>
<input type="submit>Press Me</input>
<?php
$p1 = JRequest::getVar( 'test','', 'post' );
echo $p1;
</php>

(This is an example I just wrote, not sure if it will really work)
when I press submit I get the webserver root and index.php.  How can I submit a form to the same php page?

Thanks,
timgerr
Last edited by timgerr on Tue Oct 16, 2007 3:43 pm, edited 1 time in total.
-How important does a person have to be before they are considered assassinated instead of just murdered?
-He's not carnival personnelle!!!

User avatar
jlleblanc
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Fri Aug 19, 2005 12:37 am
Location: Washington, DC / NoVA
Contact:

Re: Post a form and index.php

Post by jlleblanc » Tue Oct 16, 2007 1:34 am

Hello timgerr,

Are you putting this form in a component and trying to get back to the component, or are you putting it into an article and trying to get back to the article? If it's the former, setting option=com_nameofyourcomponent should do the trick. Otherwise, you will need to redirect back to the article in your component. This can be done with mosRedirect() in 1.0 or JApplication::redirect() in 1.5.
Joseph L. LeBlanc: http://www.jlleblanc.com
Frontend components start here: /components/com_[name]/[name].php
Backend components start here: /administrator/components/com_[name]/admin.[name].php

User avatar
timgerr
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 19, 2006 4:22 am
Location: Michigan

Re: Post a form and index.php

Post by timgerr » Tue Oct 16, 2007 2:14 pm

Here is what I am trying to do.  I have this page that I am posting information to.

Code: Select all

<?php $mosConfig_live_site ?>/index.php?option=com_backendform

when I hit the submit button I am directed to the root of my web server/index.php.  How can I create a form and post information back to the page?

thanks,
timgerr
Last edited by timgerr on Tue Oct 16, 2007 3:45 pm, edited 1 time in total.
-How important does a person have to be before they are considered assassinated instead of just murdered?
-He's not carnival personnelle!!!

User avatar
jlleblanc
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Fri Aug 19, 2005 12:37 am
Location: Washington, DC / NoVA
Contact:

Re: Post a form and index.php

Post by jlleblanc » Tue Oct 16, 2007 7:10 pm

You need an echo before $mosConfig_live_site.
Joseph L. LeBlanc: http://www.jlleblanc.com
Frontend components start here: /components/com_[name]/[name].php
Backend components start here: /administrator/components/com_[name]/admin.[name].php

User avatar
timgerr
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 19, 2006 4:22 am
Location: Michigan

Re: Post a form and index.php

Post by timgerr » Wed Oct 17, 2007 4:03 am

jlleblanc wrote:You need an echo before $mosConfig_live_site.


Yet again I have to say thanks.
-How important does a person have to be before they are considered assassinated instead of just murdered?
-He's not carnival personnelle!!!


Post Reply