WordPress : Redirect a form validation & submit - forms

What would be the best way to redirect a form after validation & submit? The form isn't a plugin, it's part of a theme.
a) This is the form action code:
<form action="" id="pro_form" enctype="multipart/form-data" method="post">
b) Here's the validation string:
<input type="submit" onclick="return validation()" value="Submit" >
Any help would be appreciated. Thanks!
Peter

I am not sure if this is want you are asking for, but in my opinion the best way is using javascript, like this:
echo '<script type="text/javascript">window.location ="NewLocation";</script>';
Place this code after the form returns from validation.

Related

Codeigniter 4 form action path

sorry for the very noob question. I have a page : www.example.com/edit/3 with form inside.
<form class="" action="" method="post">
Usually my form action I will specify something like add, register, etc. In this case, I am not sure how do I specify it. Currently it is working when I save it if I leave it blank without specifying anything. But I am not sure is this the right way to do it.
Controller
public function edit_game(){}
Routes
$routes->match(['get', 'post'], 'account/edit_game/(:num)', 'Addgame::edit_game/$1');
Can anyone advise?
action="" is the URI to which send the form data, aka the controller where you treat the received data. If not specified, it will be the same page as the one you are currently on.
What you can do:
<form method="post">
</form>
<form method="post" action=""> <!-- same as previous -->
</form>
<form method="post" action="/some/page">
</form>
In the last example, note the leading /, it means it is according to the site root. If you forget it, it will be relative to the current URI.
Exemple, if the page containing the <form> is http://example.com/edit/3:
action="/some/page" will redirect to http://example.com/some/page.
action="some/page" will redirect to http://example.com/edit/some/page

Display multiple adminForm's in joomla

When creating a custom view in joomla with multiple forms, there is a conflict because each form has the id="adminForm" name="adminForm".
Renaming the form causes incompatibility with joomla.
How can I display multiple adminForm's on a single view?
Restructure the form elements into a single page-encompassing form
and remove the &task=controller.task portion from the form action
URL, e.g.
<form
action="<?php echo JRoute::_(''); ?>"
name="adminForm" id="adminForm" class="form-validate"
method="post" enctype="multipart/form-data">
On each submit button use the joomla method: onclick="Joomla.submitbutton('controller.task')" e.g.
<button type="submit"
onclick="Joomla.submitbutton('group.join')">Join</button>
Joomla will automatically update a hidden field with the name="task" and value="controller.task" which will get submitted with the form.
You need to have this element in your form for it to work, e.g.
<input type="hidden" name="task" value="" />
</form>

Magento: How to redirect on form submit

I'm using Magento CE 1.7.
I created a CMS page to add 'Terms Of Use' to it and at the bottom of the page I added a simple "Accept Terms" submit form to have the customers agree to the terms before they can access the page I want them to access. Here's the code.
<form action="url-to-go-to.html" method="GET" onsubmit="return checkCheckBox(this)">
I accept: <input type="checkbox" value="0" name="agree">
<input type="submit" value="Continue">
<input type="button" value="Exit" onclick="document.location.href='BACKTOWHAT.html';">
</form>
<script type="text/javascript">
<!--
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert("Please tick the box to continue");
return false;
} else
return true;
}
-->
</script>
The only problem I have is that in I can only get it to work by entering the URL to the page I want them to be redirected to. i.e.
<form action="domainname.com/shop.html"> <!-- store section to go to -->
/* and the same goes for */
onclick="document.location.href='domainname.com';"> <!-- back to storefront -->
I wanted to use something else rather than the URL but I'm not sure how to do it. I thought using something like this would work.
<form action="<?php echo $this->_redirect('shop.html'); ?>" method=.... >
but it didn't.
I believe if this has been within a .phtml file it would've worked but I'm working with a simple CMS page and I know magento functions work in CMS pages but I don't know a function that would work for this purpose.
Ok, I figured it out after testing a bit more. (I'm still learning how to code)
It's quite simple, the form action should be like this instead.
<form action="{{store direct_url='shop.html'}}" method=..... >
and to redirect back to the store front on "exit" this is what worked.
onclick="document.location.href='{{store direct_url=' '}}
This worked perfectly. hope it helps others.

iframe post-form using fb:friendselector passing values

I am trying to build an facebook-iframe application, where you can select friends to send them some information.
So i build a form method="post", put in some input fields, and a friend selector.
The fb:friend input field is renderd .. works fine.. but it doesn't pass over the selected friends.
Do i have to fix it by javascript?
Is there a simpler solution?
thx sven
Code:
<form action="http://xxx.net/index.php" method="post" target="_top">
<input id="sometext" name="sometext" type="text" size="30" maxlength="30">
<br/>
<fb:serverFbml>
<script type="text/fbml">
<fb:fbml>
<fb:friend-selector uid="$user" name="$user" idname="friendselector"/>
</fb:fbml>
</script>
</fb:serverFbml><input type="submit" name="submit" value="Send">
</form>
Actually, to my knowledge you can't fix it with Javascript.
I need more details (!), but it sounds like you may be attempting to use the FBML implementation of fb-friend-selector, without fb-request-form.
If so, try this: https://developers.facebook.com/docs/reference/fbml/request-form/
(!) Can you post your HTML code here? It's likely an implementation issue that we can figure out through your code.
Ok, i am not alone, so here is an other way to cope with it.
Facebook-like styled Multifriendselector.
http://mike.brevoort.com/2010/08/10/introducing-the-jquery-facebook-multi-friend-selector-plugin/

Checking multiple forms for submission on the same page in coldfusion

Hello again stackoverflow...
Once again I have a troublesome problem. I have a page where I am using jQuery tabs to divide up three update forms. (Two really, one is a cfgrid so it doesn't really count.) Basically, when you submit the first form tab it is fine. However, if you submit the last form, it submits and refreshes the page but nothing was updated.
I've determined it has something to do with identifying which form is being submitted.
Note: These forms are being submitted to same page they are on so I am using this method:
<cfif isdefined("form.submit")>
//database stuff etc
</cfif>
I am submitting the forms by doing this at the end:
<input type="submit" name="submit" id="button" value="Save Changes" onclick = "form.submit()" />
After determining it had something to with identifying which form is being submitted, I changed the button to be:
<input type="submit" name="submit" id="button" value="Save Changes" onclick = "document.forms["form3"].submit()" />
I'm not sure if this is the most efficient way to do this...and I'm not sure how to specific that form3 is being submitted in the coldfusion part...I tried:
<cfif isdefined("form3.submit")>
but this doesn't work. It does not follow through the code.
Note: I'm using coldfusion 8. Also, using CFAJAX tags are limited because our ITS department didn't set up coldfusion correctly on the server...and they don't believe me. Thus I'm kind forced to do it in this ...weird way. It only support cfgrid for some weird reason...
ColdFusion (nor any server-side language) does not know what ID your forms might have - it only knows what you submitted via input (and select/textarea/etc) fields, and puts it in the form scope.
To do what you want, you need to have forms somthing along the lines of:
<form>
....
<input type="submit" name="submit1" value="Save Changes"/>
</form>
<form>
....
<input type="submit" name="submit3" value="Save Changes"/>
</form>
Then on the CF side you check which form it is with:
<cfif StructKeyExists(Form,'Submit1')>
...
</cfif>
or
<cfif StructKeyExists(Form,'Submit3')>
...
</cfif>
Hah, I figured it out! You have to make the submit names different on each form.
<input type="submit" name="submitDoc" id="button" value="Save Changes" onclick = "document.forms["form3"].submit()" />
I just changed the submit name to submitDoc
<cfif isdefined("form.submitDoc")>
Works!