Unable to submit the form on laravel6 - mysql

while submit the form pages using get method, does not send to the controller but I print the link on browsers to get the results, I used gates and policies on web routes, i used pagination of forms as below links, two pages contains
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_form_steps

Please use your form method POST request ,
like this :- form method="POST" action="{{ route('yourSubmitingRoute') }}"

Related

Trying to open a page after submit in a form

I'm trying to add a confirmation page after a submit on a form but i can't figure out why it doesnt work.
I'm working on Prestashop and my action look like that :
<form action="{$urls.pages.contact}" method="post" {if $contact.allow_file_upload}enctype="multipart/form-data"{/if}>
i tried differents things like target="_blank" or action="website.com & {$urls.pages.contact}"
The "action" tag of a form value is the URL where the values of post request are sent. It means that you should have a controller+method which must intercept and process those values at this address (URL, route, call it as you want).
Its not mandatory to do it this way since you can send your data with Ajax, but it's not what you want.
A proper way to do what you want is to set the "action" as a route which refers to a controller::method which process your Post data, then redirect to a page with the Tools::redirect() method.

HTML Form arguments to angular page

I have a static HTML page with a form on it asking for very basic information (Name, email).
This form will help pre-fill 2 fields of the registration process of my angular app.
the problem is that the URL that is being generated when submitting the form is
http://server/?name=xxx&email=xxx#yyy.com/#/account/create/infos
What my angular app is expecting is :
http://server/#/account/create/infos/?name=xxx&email=xxx#yyy.com
any idea how I can achieve that ?
thanks a lot
you can try setup your form to method post
<form method="post">...
Then in controller you get post-param and process it

How redirect login.html to chat.html page after successful logged in Django framework?

I have used template/login.html for logging in, after successful logged in how to redirect the login.html page to chatwindow.html page (some other html) in Django framework.
So, do I need to redirect it from views.py file or from login.html?
Any help highly appreciated.
Django implements multiple ways to do this:
1. LOGIN_REDIRECT_URL
This is a global setting in your settings.py. It works for all login pages when next= parameter is not specified in login url (e.g. example.com/login?next=/foo).
2. Use next parameter in the login URL
This is usually used to customize the login redirect for individual cases.
The common use-case is when you use #login_required decorator. When a user tries to access a page which requires authentication, a user is then redirected to a login page with a next= parameter pointing to the current page. For example if the user went to /secure/page, then the login page will be something like /login?next=/secure/page. After the user will successfully authenticate, Django will redirect them back to the protected page.
3. Use the hidden input next on the login page
Finally you can set the redirect path in the login form itself:
<form method="POST" ...>
<input typy="hidden" name="next" value="/secure/page">
...
</form>
I would guess that first method might be the most appropriate in your case however keep in mind the other options if you will need them.

Django HTTP post to same URL

What is the "proper" django way to do an HTTP POST to the same page when a button is clicked in that page?
I've got a django app which contains a page with two different buttons. Each button does a different thing but the results of the button press are returned in JSON format which then gets used to update the UI on the page.
I can obviously have each button submit to its own view and do it that way. But I can also make the page view respond to the button presses and detect whether the request is a POST or not.
Then there is the JSON mixin stuff - is it worth trying to use that somehow?
I've got it all working - I'd just like to know what the "proper" way to do it would be.
Any ideas?
As Mikko Ohtamaa said, common practice is to check in your view which button was pressed. e.g.:
template.html:
<form method="post" action="">
{{ obj_form.as_p }}
<button name="action1" value="1" type="submit">
<button name="action2" value="1" type="submit">
</form>
views.py:
if 'action1' in self.request.POST:
form = Action1Form(request.POST)
elif 'action2' in self.request.POST:
form = Action2Form(request.POST)
Using several forms in a single view is more convenient when you have one HTML form with different actions. If you have separate forms (or don't have them at all), I suggest using separate views for each action.

Rails 3, make submit call specific function in controller

new to web development, here. I have a form like this:
<form name="myForm" id="myForm" method="post" >
<select id="id" name="foo">
...some stuff
</select>
<input type="submit"/>
</form>
The submit button calls the 'index' method of my controller, as expected. I would like to make it call some other function, such as 'update', how do I do that? I need to do something with the #_params hash, but I don't want invoke the index function, to do it. Thanks.
You did not include the view logic so I am going to take a stab in the dark and guess you are writing the HTML for the form rather than using the RoR helpers.
In rails there are a set of helpers that help you generate forms and form items.
Please check the docs for form_for
Using form_for will follow the basic restful routing unless you modify the url parameter. So if you are on /new you will be routed to /create, if you are on /edit, you will be routed to /update. More precisely, if the object is new, you will submit to create, if the model exists you will submit to update.
If your form doesn't use a model, you can use the form_tag helper that takes a url parameter and you can pass a string specifying what path to submit to.
If you just need to know how to do this in plain HTML, read this. Essentially, you need to include an action attribute on form that specifies the path to the action you want to post to.