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
Share on other sites

<a href="{$this_path}page.php" onclick="javascript:post_Form.submit();"

needs to be

<a href="{$this_path}page.php" onclick="javascript:post_Form.submit();">

 

and you have nothing inside that a tag, is that correct?

Link to comment
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.