Jump to content

Keep same URL when form submitted


glenelkins

Recommended Posts

Hi

I want to keep a url as the same when a form is submitted, the form:

[code]
<form action='?a=shout' method='post'>
[/code]

this is all well and good though i have a file called 'module.php' which selects the module to display from 'module.php?mod=modtag' if i use the forum construct as above, it loads only module.php without the 'mod' so not displaying the same page but the default empty module
Link to comment
https://forums.phpfreaks.com/topic/26838-keep-same-url-when-form-submitted/
Share on other sites

No sorry, that wont work, the script does not know what module it is on at that poiint. Im writing a cms and one of the blocks runs a seperate script for a shoutbox. that script has no idea of the current module. Though i suppose i can get it to take $_GET['mod'];
Try:

[quote]echo '<form action="?'.(!empty($_GET['mod'])?$_GET['mod']:'').'&a=shout" method="post">';[/quote]

Not the best for readability but it does the job :).

Simply checks to see if the GET variable has a 'mod' value. If so returns it, if not returns an empty string. The result is concatonated and everything should work fine.

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.