Jump to content

PHP TPL and POST


Zuko9215

Recommended Posts

Hello forum,

i have 2 files. a page.tpl and a page.php , and what i want is when the user clicks the hyperlink , to be redirected in page.php and also post the post_Form in page.php.

the user is of'course riderected but the form is not posted..

What i ve tried the following code..

 

page.tpl

<p class="class1">
<a href="{$this_path}page.php" onclick="javascript:post_Form.submit();"</a>
               <form name="post_Form" action="{$this_path}page.php" method="post" />
                  <input type="checkbox" name="test_checkbox" value="true" /> something<br />
                  <select name="cases">
                     <option value="case1">1</option>
                     <option value="case2">2</option>
                 </select>
               </form>

 

page.php

if (!isset($_POST['test_checkbox']))
{
     //do something
}

 

Please help.. thanks

Link to comment
https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/
Share on other sites

notice i closed the tag, the last character.

not closing an a tag sometimes messing everything up!

 

Yeah. That was a copy paste typo. In my next post(where i ve included title and image) its the right one

 

If you're redirecting a user after the submit something I'd add Header at the end of the code that executes.

 

<?php

if (!isset($_POST['test_checkbox']))
{
     //Your code your excuting
   Header("Location: pageyouredirectto");   

}

 

ok. but thats not the problem now. the test_checkbox is never set, probably because. its never posted in this page (throught post_Form)

Link to comment
https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1207832
Share on other sites

Ummmm.... I would suggest removing $this_path on the form action and just do ./page.php or something, see if it posts then, if it does then look into whatever you set $this_path

 

no luck... the code inside

if (!isset($_POST['test_checkbox']))

is always executed,, which means its never set. wether iv checked the checkbox or not

Link to comment
https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1207847
Share on other sites

thanks for the help guys..

Ok, so i tried this:

 

<a href="javascript:post_Form.submit();" onclick="location.href('{this_path}page.php');" title="{l s='Something'}">
	<img src="{$this_path}image.gif" alt="{l s='Something'}" />
</a>

 

and it worked. But i realized that the code inside page.php was being executed twice.

So i changed it, to just this:

 

<a href="javascript:post_Form.submit();" title="{l s='Something'}">
	<img src="{$this_path}image.gif" alt="{l s='Something'}" />
</a>

 

and it worked perfectly. (form was posted succesfully, i was redirected to page.php and code executed once)

So, Solved. :]

Link to comment
https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1208073
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.