glenelkins Posted November 10, 2006 Share Posted November 10, 2006 HiI 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 More sharing options...
blear Posted November 10, 2006 Share Posted November 10, 2006 1) Alter the ACTION= ' ' part to include '&mod=modtag' OR2) Put a hidden input with value 'modtag' and name 'mod' into the form[code]<input type='hidden' name='mod' value='modtag'>[/code] Link to comment https://forums.phpfreaks.com/topic/26838-keep-same-url-when-form-submitted/#findComment-122712 Share on other sites More sharing options...
glenelkins Posted November 10, 2006 Author Share Posted November 10, 2006 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']; Link to comment https://forums.phpfreaks.com/topic/26838-keep-same-url-when-form-submitted/#findComment-122715 Share on other sites More sharing options...
nrobi Posted November 10, 2006 Share Posted November 10, 2006 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. Link to comment https://forums.phpfreaks.com/topic/26838-keep-same-url-when-form-submitted/#findComment-122718 Share on other sites More sharing options...
glenelkins Posted November 10, 2006 Author Share Posted November 10, 2006 got it , if i leave action='' and set a hidden field to trap the action it works Link to comment https://forums.phpfreaks.com/topic/26838-keep-same-url-when-form-submitted/#findComment-122719 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.