Zuko9215 Posted April 28, 2011 Share Posted April 28, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/ Share on other sites More sharing options...
JKG Posted April 28, 2011 Share Posted April 28, 2011 <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? Quote Link to comment https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1207780 Share on other sites More sharing options...
Zuko9215 Posted April 28, 2011 Author Share Posted April 28, 2011 I also have a title and and an image if thats what you r asking <a href="{$this_path}page.php" onclick="javascript:post_Form.submit();" title="{l s='Something'}"> <img src="{$this_path}image.gif" alt="{l s='Something'}" /> Quote Link to comment https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1207787 Share on other sites More sharing options...
Zuko9215 Posted April 28, 2011 Author Share Posted April 28, 2011 needs to be what.? You posted the exact same thing,,.. Quote Link to comment https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1207790 Share on other sites More sharing options...
JKG Posted April 28, 2011 Share Posted April 28, 2011 notice i closed the tag, the last character. not closing an a tag sometimes messes everything up! Quote Link to comment https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1207823 Share on other sites More sharing options...
Tonic-_- Posted April 28, 2011 Share Posted April 28, 2011 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"); } Quote Link to comment https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1207829 Share on other sites More sharing options...
Zuko9215 Posted April 28, 2011 Author Share Posted April 28, 2011 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) Quote Link to comment https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1207832 Share on other sites More sharing options...
Tonic-_- Posted April 28, 2011 Share Posted April 28, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1207840 Share on other sites More sharing options...
Zuko9215 Posted April 28, 2011 Author Share Posted April 28, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1207847 Share on other sites More sharing options...
Zuko9215 Posted April 29, 2011 Author Share Posted April 29, 2011 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. :] Quote Link to comment https://forums.phpfreaks.com/topic/235014-php-tpl-and-post/#findComment-1208073 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.