Stop the 'submit' button value from being passed via GET? - html

I'm trying to pass form information via GET - this is important so that people can send the filtered data from their form selections to other people.
The problem is, using the code below, it not only passes the filter information, but also the submit form value like so: index.php?month_filter=Feb&year_filter=12&Submit=Filter+Table
<form name="filter_form" action="<?php echo CURRENT_PAGE ?>" method="get">
<input name="Submit" type="submit" class="button" value="Filter Table">
Long shot, but is there a way to remove the submit button from the URL? Thanks!

If you remove the name attribute, it will not get passed through in GET/POST.

Related

How to submit HTML label using a URL parameter?

I have the following code:
<input type="submit" class="button" value="<?php yourls_e( 'shorten!!!!! ヾ(≧▽≦*)o', 'isq_translation'); ?>">
(dont mind the php it is just for translation)
I want to be able to submit this input through a URL parameter. Example: https://example.com/?submit=true or something like that. Is there a way to do this?
Give the input a name. It can't be a successful control without one.

HTML form that causes a GET request

Basic question. If I have a form in my HTML (where in my case someone inputs a date), how can I have my users cause a GET request with the contents of that form instead of a POST.
e.g. form entry (e.g date)... so 20190312
what I am trying to achieve is such that AFTER the user submits the form.. the user is the lead to page that has
GET domain.tld/scriptname.php?variable=20190312
and then the system then processes the GET request accordingly.
thank you
Maybe i'm missunderstanding what you are asking.
This can easly be achived using builtin GET method in FORM tag
<body>
<form id="form" method="GET" action="scriptname.php">
<input id="date-txt" type="text" name="date">
<input id="search-btn" type="submit" value="Submit">
</form>
</body>
While filling up above field ad clicking "Submit" form will be submitted and you can see in your url path/or/page/scriptname.php?date=INPUT_FIELD_VAL
for every input in #form with a name, if GET method is used, you'll see a ?name=value in the url
What you describe is the default behaviour of a form. If you don't want a POST request, then don't use a method attribute to set the request type to POST.
<form action="//domain.tld/scriptname.php">
<input name="variable" value="20190312">
<button>Submit</button>
</form>

How to design form tags button in html

I have a button that is this <button id="btnSubmit">Submit</button> the problem is, I want the form tags to use this id so that is designed the way I want. And also this code, I have a few questions.
<form action="demo_form.php" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
what is the action="demo_form.php",input type="submit" do? And does the input type has any other "What do you call this stuff" besides submit?
The action="demo_form.php" sets the action, in this case, "navigate to file demo_form.php and send it the data".
<input type="submit" (...) > creates and element which submits the form e.g. executes the "action".
The method sets the way the data is submitted to the target of the action ("form_demo.php"), in this case get, which allows you to refer to the submitted data as $GET["name"] in PHP.
Possible input types are listed here.
You either give your <input type="submit" (...) > the id="btnSubmit" property or use javascript to submit the form after an event has been triggered.
MOr info on that is available here (i short: document.<get_the_form_element>.submit();).
I suggest you to take a look at this link. It describes all the basic concepts about how using forms. And you can also find a lot of information by Googling it.
The action attribute
The action attribute defines the action to be performed when the form is submitted.
The common way to submit a form to a server, is by using a submit button.
The input attribute
<input type="submit"> defines a button for submitting a form to a form-handler.
The form-handler is typically a server page with a script for processing input data.
If i understand your question correctly, these are my answers.
action
The action attribute describes the page to which the contents of the form are sent to. So if you have a sign up form with an input for an email, the text that is typed will be sent to the action path. It will be sent using the method described in the method attribute. So you can find your values in either the $_POST variable, or the $_GET variable, get is easy for being able to share the url and post is great for private information.
input
The input element is the actual way to input information (who guessed it). You've got an input of the type text for just text input, you've got checkbox for a true or false input and way way more see: w3schools
why don't you use
<input type="submit" value="Submit" id="btnSubmit">
Or if you want to use a button
<button id="btnSubmit">Submit</button>
Then from jquery or js you can submit the form.
And for this question,
what is the action="demo_form.php",input type="submit" do?
You should probably google it out. This is so basic.
Anyway, just a concise explanation:
action is the attribute where you will specify the code that will handle the form data submitted and input type="submit" will display a button in the page, clicking on it will submit the form.
There are a lot of types in input, the most common ones are
text
password
submit

HTML Form Action: How to fetch text field & create a URL for Action (Method: POST)

I have a form like:
<form method="post" action="http://www.2-myWebSiteUri.com/file1.php" id="login">
<input type="text" name="TEXTBOX1"></input>
<input type="text" name="TEXTBOX2"></input>
<button type="submit" class="button" title="login" name="send" id="send2">Login</button></form>
I would like to perform custom "action=" in FORM using POST (method) however I am not getting how to perform it. Form action should be like, for example:
<form action="http://www.2-myWebSiteUri.com/TEXTBOX1/file1.php" method="post" id="login">
BUT form should collect the text value (TEXTBOX1) from the TEXTBOX1 which user will enter and same should be used as a input value in action URL as given above in the place of TEXTBOX1. Suppose in TEXTBOX1, I have written input value as "pasta" & submitted via button, then action url should be like:
<form action="http://www.2-myWebSiteUri.com/pasta/file1.php" method="post" id="login">
or if input value is noodles then action url should be like
<form action="http://www.2-myWebSiteUri.com/noodles/file1.php" method="post" id="login">
upon submission.
I've small authentication based scripts in different directories of domain
www.2-myWebSiteUri.com and I am trying to create a single form so that all can be logged in using a single form. User will just enter directory name "such as pasta and noodles as given in above example". This form will be hosted on another domain www.1-myWebSiteUri.com and when user wants to make login any of the scripts then he will open:
www.1-myWebSiteUri.com/login.php and this is the same login form for which I want to have custom actions.
Actually, I am trying to use directories as a category of games which host few online games. Categories will not be fixed and it will be added randomly, so i want to keep TEXTBOX instead of a Drop Down. We may halt few features in the game for different users. You can take this as a different directories with different games which can be accessed only via authentication. I just want to post all the credentials using a single form instead of 100 forms for each game and it will be very tough to share all these login links with users.
I have tested couple of codes including javascripts however none of them are working. I will be more then happy if any of you assist me in this regard.
No, that will not work.
You need a middle-ware script. Your description is lacking detail but this may help.
Change action destination to middle.php
<form method="post" action="http://www.2-myWebSiteUri.com/middle.php" id="login">
<input type="text" name="TEXTBOX1"></input>
<input type="text" name="TEXTBOX2"></input>
<button type="submit" class="button" title="login" name="send" id="send2">Login</button></form>
middle.php
Value of TEXTBOX1 is inserted into url as $txt1.
<?php
$txt1 = trim($_POST['TEXTBOX1']);
$txt2 = trim($_POST['TEXTBOX2']);
include("http://www.2-myWebSiteUri.com/$txt1/file1.php");
?>
Depending on values of TEXTBOX1 you may need to add urlencode:
$txt1 = urlencode(trim($_POST['TEXTBOX1']));

php mail / submit a variable span

I am trying to submit a <span> value to be mailed through php.
I want to submit the variable span res1:
<form method="POST" name="results" action="message.php">
<span id="res1">Mail This:*this part varies*</span>
</form>
using this handler:
$body .= $_REQUEST['#res1']." \n";
mail( $recipient, $subject, $body, "From: $sender" ) or die ("Mail could not be sent.");
I'd prefer for the <span> to not be in the form; i'm not sure if this is possible though?
Excuse my ignorance - never worked with server side stuff before! Thanks to anyone who can help me!
How does this part varies get to the span? Use the same instruction to add a
<input type="hidden" name="res1" value="the same value you put in the span"/>
Then, in your PHP code you can get the value with $_REQUEST['res1'] or $_POST['res1'] -- note the removed hash.
Update
For anybody who might make a similar mistake, here is what would work and what wouldn't.
HTML forms only send the values of form controls when submitted. They are:
inputs of various types (text, password, radio, checkbox, hidden, file, submit, image, or newer HTML5 inputs like email, etc.)
selects
textareas
Furthermore, the value of an input is only submitted if it has been assigned a name. So if the following inputs are in a form, on submitting the form whatever value bugs may have will be submitted, but nothing will be submitted for bunny:
<input type="text" name="bugs"/>
<input type="text" id="bunny"/>
So, putting any element between <form> ... </form> does not cause the text inside it to be submitted. For a value to be submitted it should be one of the above form controls AND it should have a name property set.
You can do this:-
<form method="POST" name="results" action="message.php">
<input type="hidden" id="res1" value="some text" />
</form>
You can use javascript to access and change "res1"
document.getElementById("res1").value=some variable or textbox content;