is there any way to send METHOD value in <a> tag - laravel-controller

when I send edit request to edit() using <a> it's working because of 'GET', but for Delete, I have to send a request for Delete Method also, How I can send it without using the form like edit
Edit
<form action="{{url('/auctions',$auction->id)}}" method="POST">
#csrf
#method('DELETE')
<input type="submit" class="btn btn-danger"
value="Delete">
</form>
I just want to know that we can send METHOD value by <a> Or Not

Clicks on links via link are always GET requests and cannot be anything else.

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

How do I get this Newletter Form to work?

I'm not sure what to put in for href:\ Should I reference a mailhandler.php or use a mailto: command? Or is there something better?
<h3 class="margin-bot">Newsletter!</h3>
<form id="subscribe-form" name="sibscribe" method="post">
<label><input class="subscribetext" type="text" onFocus="if(this.value =='Enter E-mail:' ) this.value=''" onBlur="if(this.value=='') this.value='Enter E-mail:'" value="Enter E-mail:" name="keyword" /></label>
<a onClick="document.getElementById('subscribe-form').submit()" class="button" href="#">subscribe</a>
</form>
I think it is meant for the site to which you get after pressing the subscribe button. Preferably the page the form was implemented in (for example to return to the index.html).
You can try it by testing it here on jsfiddle (http://jsfiddle.net). Just put an URL in the field where now is the # and after pressing subscribe you will see that you'll be redirected to that page.

POST request in GWT

i first tried to make request to server with GET method and it works fine. my request would process a file then return as a pdf file and would open on a new browser. what i did is overriding the doGet() method. since having a GET request is only limited to few parameters, i must change it to doPost() mehod but the problem is that it can't be overrided because the method is final.
in an HTML FORM, what i wanted to happen is something like this:
<form method="post" action="http://differentdomain.com/appserv/appserv.php">
<input type="hidden" name="fwi_script" value="app/custom/cusapp/interface" />
<input type="hidden" name="trx" value="<trx>
<productid>PROD1</productid>
....../** transaction details here */
</trx>" />
<input type="hidden" name="fcompanyid" value="SHOST101" />
<input type="hidden" name="fwi_action" value="PRINT_PENDING_SALES" />
<input type="hidden" name="fexcel" value="0" />
<input type="submit" value="Submit" />
</form>
this html form will print the order slip of every transaction when user clicks on the post order button.
anyone can give an idea on how to POST request in GWT server? i think i can't do it with RequestBuilder since i will be having the SOP problem since i will be connecting to a different domain.
To build very nearly the same html you have in your question, start with a FormPanel and add the form fields you need to it. Make sure to configure the FormPanel with the correct action and method, and to provide names (and possibly values) to the fields added to it. To fire off the request, submit() can be called.
The solution is to make a normal GWT RPC call to your server and have the server make the POST request to the server located on a different domain.

How to capture current dynamic output of JSP and email it?

In my webapplication, a JSP page outputs to the webpage, the list of users logged in that day. I want to mail the same output to specifics mail-ids. What all Struts2 tags do I need to use?
Grab the HTML using JavaScript and send it as request parameter.
<div id="content">
... (here you should put content which you'd like to mail)
</div>
<form action="mail" method="post" onsubmit="html.value = encodeURIComponent(document.getElementById('content').innerHTML)">
<input type="hidden" name="html" />
<input type="submit" value="Mail this document" />
</form>
It'll be available as request parameter with name "html" in Struts2/Servlet side. The emailing job can be done with help of JavaMail.

PHPSESSID appears in form arbitrarily

I have a login form written in PHP and each time I start the browser and go to the respective page, the first field of the form is this:
<input type="hidden" name="PHPSESSID" value="session_id_code" />
If I close the window, but I don't restart the browser, this doesn't happen. Any idea what's happening and why?
Thanks!
Form's code:
<?php
if (condition) {
?>
<form method="post" action="">
<dl>
<dt>Email:</dt>
<dd><input type="text" name="useremail" /></dd>
<dt>Password:</dt>
<dd>
<input type="password" name="userpass" /></dd>
<dt class="dt-buttons"><input type="submit" name="button_login" value="Login" class="button" /></dt>
</dl>
<input type="hidden" name="formkey" id="formkey" value="224ca00155w2fcda8906e1e40af03a71" />
</form>
<?php
}
?>
The form is simple HTML and is not dynamically generated.
EDIT2:
As I was saying, when I access the page for the first time after I started the browser, this thing happens. If I refresh the page afterwards, the hidden field doesn't show up.
Is it possible to have something to do with the SSL certificate? And if yes, why some pages/forms behave like this and some don't?
Sounds like you've got trans_sid enabled (transparent session id). Using trans_sid can be a security issue, especially if your site links to external content, or you allow link sharing - it lets a user's session ID leak out as part of the URL, meaning the session is highly vulnerable to hijacking.