Html form get request not adding the form data - html

I'm making a desktop app that requires user to activate a key.
So the form here is making a get request to the api.
How do I make it so that when the user submits a form data (a key)
it is added as a parameter in the string?
UPDATE: Question answered.Thanks!
But can anyone tell me how to make it so if the key is valid, the software loads, but if not then it throws an exception?
<form method="get" formenctype="text/plain" action="https://app.cryptolens.io/api/key/Activate?token=blahblahblah&ProductId=xxx2&Key=" >
<input type="text" maxlength="23" size="80" placeholder="XXXXX-XXXXX-XXXXX-XXXXX" />
</form>

I don't think you quite understand how GET works. Get sends data via the URI, any field(using the 'name' property) you add into your form is added to the query string.
<form method="get" formenctype="text/plain" action="https://app.cryptolens.io/api/key/Activate" >
<input type="text" name="token" maxlength="23" size="80" placeholder="XXXXX-XXXXX-XXXXX-XXXXX" />
<input type="text" name="ProductId" maxlength="23" size="80" placeholder="XXXXX-XXXXX-XXXXX-XXXXX" />
<input type="text" name="otherData" maxlength="23" size="80" placeholder="XXXXX-XXXXX-XXXXX-XXXXX" />
</form>
This will produce: https://app.cryptolens.io/api/key/Activate?token=VALUE&ProductId=VALUE&otherData=VALUE
Note I also removed the query string from the ACTION="" As the request will do that automatically for you.
EDIT: I also wouldn't recommend having your token in plain view. Either you make it a hidden field or you use javascript to execute the request with some masking. Hidden is usually fine providing the API has the necessary security to handle it.

Using hidden inputs and naming them like the GET you need.
Check the name token with hidden value like example.
Remove all the GET from the action-url.
The final URL will be: https://app.cryptolens.io/api/key/Activate?Key=yourKey&token=blahblahblah&ProductId=xxx2
<form method="get" formenctype="text/plain" action="https://app.cryptolens.io/api/key/Activate" >
<input type="text" maxlength="23" size="80" name="Key" placeholder="XXXXX-XXXXX-XXXXX-XXXXX" />
<input type="hidden" name="token" value="blahblahblah" />
<input type="hidden" name="ProductId" value="xxx2" />
</form>

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

How to send hidden data

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.

Sending textbox inputs to email HTML

I'm working on a page where I have 2 textboxes.
I want to send the user inputs for these 2 mailboxes to my email but my code doesn't seem to work. Is there anything I've missed?
<form method="post" action="mailto:youremail#youremail.com" >
First:<input type="text" name="First" size="12" maxlength="12" />
Last:<input type="text" name="Last" size="24" maxlength="24" />
<input type="submit" value="Send Email" />
</form>
Your code is correct, it does work for me. It probably doesn't work for you because you don't have an email client, or your browser turns off this feature for security (or something like that). I would recommend that you use a service to perform this action such as http://www.braveapps.com/emailfwd/ or http://allforms.mailjol.net/.

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>

POST extra values in an HTML <form>

I have a simple form which passes the value of an <input /> element:
<form action="updaterow.php" method="POST">
<input type="text" name="price" />
</form>
How can I post extra values along with the <input /> value? For example, an arbitrary string, or a variable inside the current PHP script.
I know this is possible with GET:
<form action="updaterow.php?foo=bar" method="GET">
<input type="text" name="price" />
</form>
or:
<form action="updaterow.php?foo=<?=htmlspecialchars($bar)?>" method="GET">
<input type="text" name="price" />
</form>
but I need POST.
You can include a hidden form element.
<input type="hidden" name="foo" value="bar" />
You can simply use a hidden field. Like so:
<input type="hidden" name="your-field-name" value="your-field-value" />
This field will then be available in your PHP script as $_POST['your-field-name']
As mentioned already, using hidden input fields is an option, but you can also use a session. That way you donĀ“t have to post anything, the variables remain on the server and are not exposed in the html.