Page 1 of 1

Post a form and index.php

Posted: Mon Oct 15, 2007 9:10 pm
by timgerr
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

Re: Post a form and index.php

Posted: Tue Oct 16, 2007 1:34 am
by jlleblanc
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.

Re: Post a form and index.php

Posted: Tue Oct 16, 2007 2:14 pm
by timgerr
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

Re: Post a form and index.php

Posted: Tue Oct 16, 2007 7:10 pm
by jlleblanc
You need an echo before $mosConfig_live_site.

Re: Post a form and index.php

Posted: Wed Oct 17, 2007 4:03 am
by timgerr
jlleblanc wrote:You need an echo before $mosConfig_live_site.


Yet again I have to say thanks.