I have been trying to submit data with a form to some php code. The code gets $_POST['sumbit'] == 'Submit' but nothing else.
Example:
<form id="ucp" method="post" action="./ucp.php?i=nhl&mode=nhl">
<fieldset class="fields2">
<dl>
<dt><label for="teamname">Team Name:</label></dt>
<dd><input type="text" maxlength="25" id="teamname"></dd>
</dl>
<fieldset class="submit-buttons">
<input type="reset" value="Reset" name="reset" class="button2" />
<input type="submit" name="submit" value="Submit" class="button1"/>
</fieldset>
</form>
PHP:
http_build_query($_POST) == "submit=Submit" || ""
Forms need inputs with NAMEs, IDs will not work. Any input field without a name attribute does not send data.
Related
I'm not sure why my additional input information is not being submitted when the form is submitted. I have applied what I have found in a similar post to insert additional input before the form is submitted. Unfortunately, only "quesiton1answers" is submitted. Additional "time" info is not :( What's wrong with this code...
<form method="post" id="answer_form" action="./submit_test.php">
<h3>1. xyz</h3>
<div>
<input type="radio" name="question1answers" id="question-1-answers-A" value="A" />
<label for="question-1-answersA">A) <sup>253</sup>/<sub>240</sub> </label>
</div>
<input type="submit" value="Submit" name="Submit" style="font-size:32px;">
</form>
jquery:
$("#answer_form").submit(function(e){
$("<input />").attr('type', 'hidden')
.attr('name', 'time')
.attr('value','60')
.appendTo("#answer_form");
return true;
});
This should work, as many others solutions offered at topic you this code from How to add additional fields to form before submit?
You can also do it simply like this (just add hidden):
$("#answer_form").submit(function(e) {
$(this).append('<input name="time" value="60">');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form method="post" id="answer_form" action="./submit_test.php">
<h3>1. xyz</h3>
<div>
<input type="radio" name="question1answers" id="question-1-answers-A" value="A" />
<label for="question-1-answersA">A) <sup>253</sup>/<sub>240</sub> </label>
</div>
<button type="Submit" value="Submit" name="Submit" style="font-size:32px;">Submit</button>
</form>
This works as you see, if not problem is somewhere else, not in code presented. Maybe in your PHP.
I am trying to pass multiple values in a JSP page url to another one.
The code is:
<form name="QuantityForm" onsubmit="return quantityValidation()" action='<%="basket.jsp?addItem="+product.PID%>' method="post">
Quantity <input type="text" name="quantity" size="5">
<input class="button button2" type="submit" value="Add to basket" />
</form>
How do i pass the value of quantity(the field of name="quantity") in the same URL? i know it's something like "Search.jsp?item=<%=search%>&item2=value2&item3=value3.." but i can't seem to structure it properly. Thanks
Do not put your ? and parameters in the action url. Put your parameters in input tags:
<form name="QuantityForm" onsubmit="return quantityValidation()" action='basket.jsp' method="post">
<input type="hidden" name="addItem" value="%product.PID%">
Quantity <input type="text" name="quantity" size="5">
<input class="button button2" type="submit" value="Add to basket" />
</form>
you're using method="post" which doesn't allow parameters to be passed into the url. change it to method="get" if you want the parameters to be passed along with the url.
I need to add a path to a file to the form url before submitting. I created therefore a text field and want to add the text to the url without php.
can somebody help?
the existing code:
<form action="http://127.0.0.1:8080/WebService1/HTTPMethod_1?new_value=value" method="post">
<input type="text" value="" size="30" name="filename">
<input type="submit" name="submit" value="Submit" class="continue-button">
</form>
look into using hidden input fields. these allow you to send form data, but not necessarily show a form field.
for instance:
<script type="text/javascript">
function setFormAction() {
document.myForm.action = document.getElementById("url").value;
}
</script>
<form name="myForm" method="POST" action="default.php">
<input type="value" name="url" id="url" />
<input type="submit" name="submit" onclick="setFormAction();" />
</form>
I have the following form
<form name="input" action="http://testdomain.com/search/?" method="get" autocomplete="off">
<input type="text" name="?wpv_paged_preload_reach=1&wpv_view_count=1&wpv_post_id=205499&wpv_post_search=">
<input type="submit" id="searchsubmit" value="">
</form>
However the actual URL displays the following search query:
/search/?%3Fwpv_paged_preload_reach%3D1%26wpv_view_count%3D1%26wpv_post_id%3D205499%26wpv_post_search%3D=test
It seems that special symbols such as ? and = are getting replaced with special Encoding characters.
My question is, how do I get the form to not switch my special symbols with the encoding characters?
Thanks
The name of an input element controls the name of one field. The browser doesn’t blindly mash it and its value together and send that to the server. For a GET request, you can include each one as a hidden field:
<form name="input" action="http://testdomain.com/search/" method="get" autocomplete="off">
<input type="hidden" name="wpv_paged_preload_reach" value="1" />
<input type="hidden" name="wpv_view_count" value="1" />
<input type="hidden" name="wpv_post_id" value="205499" />
<input type="text" name="wpv_post_search" />
<input type="submit" id="searchsubmit" />
</form>
I am trying to pass a few parameter and a user input to a search_form.asp page.
<form action="search_form.asp" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
</form>
And on search_form.asp...
lname=request.QueryString("Lname")
fname=request.form("fname")
But I am unable to see lname when i place Response.Write("<p>Name: " & lname) in search_form.asp
The query string is not preserved when you submit the form, so search_form.asp will not have a query string. As an alternative, could you include the query string as a hidden field:
<form action="search_form.asp" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
<input type="hidden" name="lname" value="<%=Request.QueryString("lname")%>" />
</form>
And then refer to Request.Form("lname") in search_form.asp.
Alternatively, could you include the query string in the form action?
<form action="search_form.asp?<%=Request.ServerVariables("QUERY_STRING")%>" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
<input type="hidden" name="lname" value="<%=Request.QueryString("lname")%>" />
</form>
This should pass the query string on the original page when the form is submitted.