How to send hidden data - html

I have a form(like the one below for example) where I type data, but I also want to send data which are not directly entered by the user, for example a generic Id(for a user in this case)
<form name="input" action="" method="post">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>
Don't know if I have been clear enough, I hope so.

try a hidden input:
<input type="hidden" value="foo" name="user_id" />
The user can't see it, but remember that such inputs can be spoofed and need to be validated on the server just like any other input.

Related

HTML code to send SMS message through a form

I am trying to create an HTML code in order to send SMS messages through a form.
My provider give to me the Http address that i could send these SMS and it looks like bello (of course i have hide passwords, etc)
http://sms.services/send-sms?app-id=108744&password=1111111&to={1}&from=TestSender&message={0}
When i call this address with a phone number instead of {1} and a text insted of {0} it works fine.
But when i try to create the bellow page it says that the attributes are wrong.
Can you please help?
<form action="http://sms.services/send-sms?app-id=108744&password=1111111&to=telnumber&from=TestSender&message=textsms" method="post">
<input type="number" name="telnumber" />
<input type="text" name="textsms" />
<input type="submit" value="Submit" />
Change your method to GET
Make other parameters input type hidden so user will not see those but internally it will be passed.
<form action="http://sms.services/send-sms" method="get">
<input type="number" name="to" />
<input type="text" name="message" />
<input type="hidden" name="app-id" value="108744" />
<input type="hidden" name="password" value="1111111" />
<input type="hidden" name="from" value="TestSender" />
<input type="submit" value="Submit" />
</form>
Note: It is not recommended to do like it because it will expose your app-id and password. You should send it to a php or any backend framework and then from there call this.
Try to use input type="text" instead of number.
Probably, input type="number" tries to convert string to demical, but your provider use string

Redirect to selected site with variable which i got

<form action="/subsite/" method="GET">
<input type="text" name="" placeholder="Your Nick">
<input class="button" type="submit" />
</form>
I want to redirect I mean it should looks like
www/subsite/text
What should I use ? POST ?
The method="get" means that the parameters (and values) will be sent in the query string (the stuff after the question mark in the URL). eg.
/subsite?input_field_name=input_field_value
In your case, the input field doesn't have a name, which will cause problems. You probably want something like this:
<input type="text" name="nickname" placeholder="Your Nick">
So if you submit this form:
<form action="/subsite" method="get">
<input type="text" name="nickname" placeholder="Your Nick">
</form>
Then after submitting, the browser will go to:
/subsite?nickname=value_of_nickname_variable
If you use a method="post", then the form data (variables) will be sent along in the request body, not the query string. There are other differences between get/post, but that's one of them :)
If you just want to do a simple redirect when clicking the button, you could use javascript instead, eg.: window.location.href='/my_url_path_here'

HTML Form POST re-writing action attribute

I have an HTML form that I'm trying to get to post with part of a query string already inplace, but it keeps re-writing the URL.
<form id="mls_form" action="/index.php?option=com_mls&view=mls" method="get">
<label>MLS#:</label>
<input type="text" name="mlsnum" />
<input type="submit" value="Go" />
</form>
Output is:
http://www.mysite.com/index.php?mlsnum=value
It seems really simple, but I don't know why it's re-writing the action attribute.
Use the POST method rather than the GET method. The URL parameters will be sent as specified in the action attribute, and the form inputs will be sent in the post data. Your server script can then read them each using whatever API is appropriate (in PHP, $_GET versus $_POST, or find them all in $_REQUEST).
If you must use GET you can give the additional parameters as hidden input fields.
<form id="mls_form" action="/index.php" method="GET">
<input type="hidden" name="option" value="com_mls" />
<input type="hidden" name="view" value="mls" />
<label>MLS#:</label>
<input type="text" name="mlsnum" />
<input type="submit" value="Go" />
</form>

Passing form variables through URL

What I want to accomplish is logging in to a website by simply typing in the form variables in the URL.
HTML code:
<form action="httpclient.html" onsubmit="return checkSubmit();" method="post" target="_parent" name="frmHTTPClientLogin">
<input type="hidden" name="mode" value="191">
<label>Username</label>
<input border="1" style="width:150px" maxlength="60" name="username">
<label>Password</label></pre>
<input type="password" border="1" style="width:150px" autocomplete="off" name="password" maxlength="60">
This is the relevant past of the code. Now I want to login to this site http://10.100.56.55/httpclient.html just by passing values typed in the url. Firstly is it possible. If yes then what exactly do i need to type for userame :name and password being pass ?
and what encoded URL will be passed in POST method if any?
Change method="post" to method="get"
If you want to type the Querystring in for the username and password, you need to do this in the address field of your browser:
http://10.100.56.55/?username=name&password=pass
EDIT:
You need to find out where the form is going and what it's doing. For this, you need to check what the submit javascript function called 'checkSubmit()' is doing. You can do this by opening the page in your browser and doing a view source. If the javascript is external to the html file, check the js links on the page and open those up to find that function. The function might have the querystring parameters you're looking for.
<input type="text" class="form-control" placeholder="Products" name="search" value="search" id="search">
<input type="text" class="form-control" placeholder="Products" name="search" value="search" id="search2">
<button type="submit" class="btn btn-default" onclick="location.href='\search.php?search='+ document.getElementById('search').value+'&search2='+document.getElementById('search2').value;"> Search</button>
the issue was in the input tag <input type="hidden" name="min_price" value="200"> forward slash was missing,I have added the forward slash and it works now <input type="hidden" name="min_price" value="200"/>.
It's not possible to do that; the form would have to use the GET method.

pass form input value to action

I have a page (module-access.php).
On the page I have a form with one text input field. I'd like to set whatever is typed in this field to be part of the form's action.
<form action="module-access.php?company=THE-USERS-INPUT" method="post" name="company" id="company">
Company Name: <input type="text" name="textfield" id="textfield">
<INPUT TYPE="submit" name="submit" VALUE="Go"></FORM>
Thanks
Just change the input name from textfield to company and the action type to GET
<form id="myform" action="module-access.php" method="GET">
Company Name: <input type="text" name="company" id="company">
<input type="submit" name="submit" value="Go">
</form>
Why? Does it matter whether it's passed in the POST or GET? You can always just use REQUEST.
If it does matter then you'll need to use JavaScript to modify the action before you POST the form. Not very hard to do.