I've got a GET request like this:
<FORM action='vieweto0.php' method='POST'>
<SELECT name='ID_Profil'>
<OPTION value=3> blank3</OPTION>
<OPTION value=2> blank2</OPTION>
<OPTION value=4>blank4</OPTION>
</SELECT>
<br><input type='submit' type=hidden name='OK' value='choose this one'>
</FORM>
How my POST request should look like if I want to choose OPTION 'blank4'?
Where I can read more about POST request like this?
If you use python requests:
import requests
res = requests.post("http://hostaddress/vieweto0.php", data={"ID_Profil":4})
POST or GET requests are basically sending key-value pairs to the server.
Learn more about http POST on https://www.w3schools.com/html/default.asp and how requests work on this: http://docs.python-requests.org/en/master/user/quickstart/. If you are interested in the details of POST, you can read this: https://www.rfc-editor.org/rfc/rfc7231#section-4.3.3.
You can use this $_POST['ID_Profil'];
Related
I have been given the following POST instruction, and I am trying to translate it into httr:
<form method="POST" action="https://this.website.com/foldername>
<input type="hidden" name="ExternalAction" value="AgetAscii">
File Type <input type="text" name="filechar" value="0">
<input type="submit" value="Click here to Retrieve the File"/>
</form>
I am having trouble getting the right syntax for httr. I would welcome suggestions. The initial input type, name and value seem straight forward, but I don't see how I bring the File Type arguments into httr, nor am I confident I am handling the final "submit" and value items properly.
I'd welcome suggestions.
Many thanks
If I paste that example html into an local html file and substitute the action to be http://bin.org/post like so:
<form method="POST" action="http://httpbin.org/post">
<input type="hidden" name="ExternalAction" value="AgetAscii">
File Type <input type="text" name="filechar" value="0">
<input type="submit" value="Click here to Retrieve the File"/>
</form>
Then the only form data reported back by httpbin.org as having been received are for ExternalAction and filechar. Therefore, to send this data via httr::POST() you would do:
library(httr)
action <- "https://this.website.com/foldername"
body <- list(ExternalAction = "AgetAscii",
filechar = "0")
POST(url = action, body = body)
I have a simple problem yet it seems impossible to solve in AMP!!
I have a simple form with an input and a submit button like this:
<form id="myform">
<input type="text" id="srchInput"/>
<button type="submit">Submit</button>
</form>
All I want is to be able to concat a static url to the input value and redirect the page to the result, when the form is submitted.
For instance if the user inputs: "Hello" and submits the form, I would like to redirect him to a page like "MY/STATIC/URL/Hello".
Is there any way to achieve this in amp?
One way of doing this is by setting the AMP-Redirect-To header in the response (See AMP-form-redirection). Send the user input on form submission, and then generate your desired url from your API endpoint and set AMP-Redirect-To header in your response to the generated URL.
Another way of doing it would be by using navigateTo(url=STRING) action (See AMP Actions & Events) on for the form submit event. In this case you have to store the value in input to a state by using events like input-throttled, and then use url substitution in the navigateTo url string to append amp-state value.
The first method is guaranteed to work.
The second method should work in theory, but I was unable to figure out how to get AMP-STATE value by url substitution. The code for the same should be something like:
<form id="myform" on="submit:AMP.navigateTo(url="MY/STATIC/URL/AMP_STATE(endValue)>")">
<input type="text" id="srchInput" on="input-throttled:AMP.setState({ endValue : event.value })" />
<button type="submit"> Submit </button>
</form>
If you can figure out how to substitute amp-state value to the url this should work. Let me know if it helped.
The easiest way to do this is via a GET action:
<head>
...
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
</head>
<body>
<form method="GET" action="MY/STATIC/URL" target="_top">
<input type="text" id="srchInput" name="srcInput" value="test">
<button type="submit">Submit</button>
</form>
</body>
The form submit will navigate to /MY/STATIC/URL?srcInput=test.
I wrote my own WordPress Plugin and I am trying to just refresh the page after form submit.
My code looks like this:
<form method="post" action="<?php echo get_admin_url();?>admin-post.php">
<input type="hidden" name="action" value="send_nl">
<input type="text" name="nl_title" placeholder="Title">
<textarea type="text" name="nl_text" placeholder="Message"></textarea>
<input type="submit" name="submit_nl">
</form>
If I submit the form everything works fine. I get an Email with the right data, but I get redirected to a white page: to https://www.myurl.com/wp-admin/admin-post.php! Now I would need a hook or something similar to redirect to my plugin page again.
I searched a lot, but I couldn't find the right solution - god knows why.
Thank you.
After you have send, save your date you should the function wp_safe_redirect() from the WP API to redirect to your page. A source example below.
wp_safe_redirect(
// Sanitize.
esc_url(
// Retrieves the site url for the current site.
site_url( '/wp-admin/admin-post.php' )
)
);
exit();
You see this usage here in this repo in a function to import data from a json string in the database in the full context.
I'm coding a plugin that requires forms but I'm having some troubles on post sends.
I had read that the fields names can be a problem for this... But I have 3 fields: cmbParkings, cmbTarifas and dpkFechaEntrada.
My plugin register one custom post type called parking-parkia and one taxonomy for this post type with Ciudades as name.
I don't see where the problem can be! Maybe the field values could be a problem?
Explaination of fields:
cmbParkings is a select filled with all my custom posts (value=id, text=title).
cmbTarifas is dependant from cmbParkings, it loads a metadata from the parking-parkia previously selected (by the moment, value and text = metadata value, containing any characters)
dpkFechaEntrada is a date input.
If I do print_r($_POST) on my 404 page, I see my 404 loaded with the correct values from my form in the $_POST variable.
EDIT: I had comment all fields in form and 404 page still appearing on submit.
Form without fields:
<form id="frmFormularioBusqueda" method="post" action="http://mutuaparkia.extrasoft.es/?p=2632">
<div div="divBotonReserva">
<button type="submit" id="btnEnvioParking">Reservar</button>
</div>
</form>
Form with fields:
<form id="frmFormularioBusqueda" method="post" action="http://mutuaparkia.extrasoft.es/?p=2632">
<div id="selectorParking">
<select id="cmbParkings" name="msolla-cmbParkings">
<option value="0">Elige Parking</option>
<option value="2632">Parking Goya</option>
<option value="2633">Parking Córdoba</option>
<option value="2631">Parking Montalbán</option>
</select>
</div>
<div id="divSelectorTarifa">
<select id="cmbTarifas" name="msolla-cmbTarifas">
<option value="0">Elige Tarifa</option>
</select>
</div>
<div id="divSelectorFecha">
<input id="dpkFechaEntrada" name="msolla-dpkFechaEntrada" type="date">
</div>
<div div="divBotonReserva">
<button type="submit" id="btnEnvioParking">Reservar</button>
</div>
Note: the action url exists and it is ok.
Js that change the action form when the first select is changed:
$( document ).ready(function() {
$("#cmbParkings").change(function(){
//http://mutuaparkia.extrasoft.es/?p=2632
if($.isNumeric($("#cmbParkings").val())){
//$("#frmFormularioBusqueda").attr('action', '/?p=' + $("#cmbParkings").val());
$("#frmFormularioBusqueda").attr('action', $("#txtPermalink" + $("#cmbParkings").val()).val());
}
else{
$("#frmFormularioBusqueda").removeAttr( "action" )
}
$("#cmbTarifas").html($("#cmbTarifas" + $("#cmbParkings").val() ).html());
});
});
Edit: inside if, there is a commented line that it was bad. The new line is working fine now.
Thanks to vard, he had seen that changing the action from from url/?p=id
to the custom post permalink, the code works.
<select id="dealer_information_city" name="dealer_information[city]" required="required"><option value="" disabled="disabled">Choose a city.</option>
<option value="23">California</option>
<option value="114" selected="selected">Los Angeles</option>
</select>
Here's my code i want to add a new option using crawler symfony but nothing happen anyone can help me thanks!
var_dump($crawler->filter('#used_car_step1_car_model')->addHtmlDocument('<option value="1">New Jersey</option>'));