TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,992
  • Total Topics: 21,323
  • Online today: 464
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online

Get a php article form to submit back on itself

Started by marzi, November 02, 2007, 10:55:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

marzi

Using SMF 1.1 RC3  and TinyPortal v0.9.6beta

How can I get a php article to submit back on itself to display the return page. I have read through the thread at http://www.tinyportal.net/index.php?topic=19604.0  but it has not helped me.

I start the php article with a ?> and end it with a <?php and put everything else in between so I can use the old fashioned style of php/html coding and mixing.

The article URL is http://www.marscafe.com/index.php?page=60

When the form is submitted, if I code it like this in the html section:
<FORM  METHOD=POST ACTION="http://www.marscafe.com/index.php?page=60">
only the forum board index is displayed, not the page itself.


If you test the form now it is currently set up to display the submitted results outside of Tiny Portal but I would like to keep the user totally inside Tiny Portal. The submit code is
<FORM  METHOD=POST ACTION="http://www.marscafe.com/php/menueng/menueng.php"  NAME="action" onSubmit="return Validator(this);">
<input type="hidden" name="action" value="true">


and it takes you to http://www.marscafe.com/php/menueng/menueng.php


Is it possible considering the way I have modified the use of php in the article from the way you all do it? Hope I have been clear.

IchBin

#1
try this as the action for the form.
action="', $_SERVER['QUERY_STRING'],'"

marzi

Thanks for the help.
I was not able to get any success. I tried a few different permutations. When I used http://www.marscafe.com/index.php?page=60 for the string I got
The requested URL /',%20$_SERVER%5B'http://www.marscafe.com/index.php?page=60'], does not exist.

and when I used
<FORM  METHOD=POST action="', $_SERVER['PHP_SELF'],"  NAME="action" onSubmit="return Validator(this);">
I got
404 Not Found
The requested URL /',%20$_SERVER%5B'PHP_SELF'%5D, does not exist.


Perhaps I am not using the code correctly and probably did something wrong. The action code is in the html section of the page and most likely needs to be moved into the php section to make use of the php global $_SERVER. I guess I am lost on this one.

JPDeni

I think it might be better if you just used php in the article and used echo statements to output the html, rather than

Quote
I start the php article with a

?>

and end it with a

<?php

and put everything else in between so I can use the old fashioned style of php/html coding and mixing.

It may work the way you're doing it, but it's not the way most of the rest of us doi things, and it's hard to adjust our code to fit yours.

IchBin

I fixed an apostrophe missing in my post above. Try it again and also listen to Deni. :)

marzi

IchBin,
Still no success but I believe I will be able to "ride this horse".

Thanks for the help and advice. I will take JPDeni's advice, my experience with it has been 100% satisfactory. For a historical note, the php code I am using is something I wrote a while ago and thought it would be great to have it inside of TP instead of just linking out of TP to it. Next time it will be coded to TP standards.


Ianedres

If I understand your request correctly, could you use the php article to refer back to itself, parsing the POST data once it is submitted (using a hidden value) as "menueng.php" would?


JPDeni

I have a number of php articles which have forms which submit back to the same page. I use


echo '<form  action="index.php?page=',$page,'" method="post">';


where the $page variable is defined as the page number. There's never been a problem, so I don't understand what is going on with your article. The same thing with blocks.

I understand that the structure is different than you use, but I've never used your structure and I find it difficult to wrap my brain around it to be able to translate what I do to your format.

marzi

JP,
Would you be willing to share the code of one of the "php articles which have forms which submit back to the same page"?

This website is proudly hosted on Crocweb Cloud Website Hosting.