submit via GET an email address avoiding url encoding? - email

I might have a freudian lips but i cant figure out how to send an email address to a specific url without the url encodes the AT symbol in %40...
basically i have a basic form
<form class="firstLoginform" id="firstLoginform" name="firstLoginform" method="get" action="https://myurl" >
<label for="email" >Email Address</label>
<input type="text" name="userEmail" id="userEmail" size="20" maxlength="150">
<center>
<input type="submit" value="submit" />
</center>
</form>
but i submit the form the url is gonna be like
https://myurl?userEmail=myemail%40mydomain.com
but I NEED, for soe reason of the previous settings a ul like this
https://myurl?userEmail=myemail#mydomain.com
i dont have access to the page that is receiving the variables...so i wonder if i can send the email address AS IS..
thanks!!!

No, you can't according to RFC1738, the URL Spec. The # symbol is reserved because it has a special meaning.

As Alan mentioned the URL specification (RFC1738) forbids the use of the # symbol in URLs because it's reserved for use within any type of URL. An example of this would be an FTP URL which provides the option to specify a username#host.domain syntax.
Section 3 of the RFC shows a number of cases that use the # symbol in a URL.
For this reason # along with a number of other characters can't be used as part of an HTTP URL.

No, you can't. Variables in query strings must be encoded, otherwise it isn't a valid URL.

Related

HTML Form Automation Using Ampersand (&) and Dollar Sign ($) Characters

So I am trying to automate a basic HTML form I fill out a few times each day. I am trying to open the web browser with the form completely filled out. This is often a simple task, as the & character followed by the name of the form element and a value, usually works. Where this becomes tricky is that my form elements have a placeholder that uses the $ character in its name. The code is shown below:
<input name="username" type="text" />
<input name="ctl00$ContentPlaceHolder1$PasswordTextBox" type="password"
id="ctl00_ContentPlaceHolder1_PasswordTextBox" />
<input name="submit" type="submit" value="Click" />
If you look at the name of the password tag you will see the use of the $ character twice. Normally I could just type my URL into Chrome like the folowing:
wwww.theWebSite.html&username=myName&ctl00$ContentPlaceHolder1$PasswordTextBox=myPassword
&submit=Click
The above code would normally work but it doesn't in this case. I don't know why I am getting the error but I think it is due to the use of the $ character. All I am trying to do is load my page into the browser with the above form completely filled out. Any ideas?

How to parse html forms in the Go Iris framework?

Sorry if this question is a bit basic, but how can you parse form inputs in the Go Iris framework?
Here is the form I am using
<form action="/" method="post">
Username:<input type="text" name="username">
Password:<input type="password" name="password">
<input type="submit" value="Login">
</form>
here is the route and the controller respectively
iris.Post("/", TestController)
func TestController(c *iris.Context){
username := c.Form.Get("username")//Doesn't work
password := c.Form.Get("password")//Doesn't work
}
how do I retrieve the values in the Post request after the form has been submitted, Thanks
Based off an example on the iris github page you could try c.PostValue("Username"). The code you have may also work but I think you need to capitalize the variable names. In the html template you can see the name value is lowercased, however your context is more likely going off those the variable names to the left of the actual html like Username.

How to create a form that uses "=" instead of "&" with HTTP GET?

We have a form:
<form name=input action=https://www.foo.com method=get>
<input type=hidden name=foobar>
<input type=hidden name=ticket>
<input type=text value=bar>
<input type=submit value=IN>
</form>
then in the end we will get:
foobar=&ticket=
but we need
foobar=ticket=
...what is the syntax for creating an HTML form that will put "=" instead of "&" in given places?
Replace
<input type=hidden name=foobar>
<input type=hidden name=ticket>
with
<input type="hidden" name="foobar" value="ticket"/>
The bit after the = is the parameter's value, so this is saying "submit a parameter called foobar with the value ticket."
The & comes from the "application/x-www-form-urlencoded" enctype of the form, which is the default. The other options available are described in the HTML standard, but the short story is that the encoding you want is not possible with a standard HTML form.
If Javascript is an option, you could try overriding the submission process and read the form values, building your own string according to your requirements, and direct the browser to the resulting URL.
I have a feeling this problem would be better solved by making the server at the "action" URL take the parameters in the standard & way, though...

How to get the filename of a filepicker.io picture to appear in the input field next to it

I am trying to get the filename of an uploaded picture to appear in the input field next to the picker button (for filepicker.io) . Basically I am trying to find what to put in the value field for the input tag to get the filename to appear once the picture is uploaded. Here is the code I have:
<div class="row margin" id='img-row'>
<input id="filename" disabled="disabled" value="<WHAT DO I PUT HERE?>" class="input" type="text" style="width: 360px;"/>
<input name="img" data-fp-class="form-simple-action-btn filepicker_launcher" data-fp-button-text="Choose Image" data-fp-services="COMPUTER,FACEBOOK,FLICKR,INSTAGRAM,PICASA" data-fp-container="modal" data-fp-mimetypes="image/*" type="filepicker" data-fp-apikey="#################" id='campaign-img-input' value="<php echo h($_POST['img'])"/>
</div>
Thank you for your help! I haven't found any other examples like this in the documentation.
The recommended way to do this would be to bind a function to the onchange event of the filepicker input type. Once the upload occurs, the function will be called, and you can pull the filename out of the e.fpfile attribute.
Alternatively, it may be easier to use the filepicker.pick call directly given that you are interested in customizing the behavior. The widget is great for a drop-in solution in many cases, but if you're looking to customize further I'd recommend using the javascript api directly.

How to change a form's action in Lift

I am building a Lift application, where one of the pages is based on the "File Upload" example from the Lift demo at: http://demo.liftweb.net/file_upload.
If you look at the source code for that page... you see that there is a Lift "snippet" tag, surrounding two "choose" tags:
<lift:snippet type="misc:upload" form="post" multipart="true">
<choose:post>
<p>
File name: <ul:file_name></ul:file_name><br >
MIME Type: <ul:mime_type></ul:mime_type><br >
File length: <ul:length></ul:length><br >
MD5 Hash: <ul:md5></ul:md5><br >
</p>
</choose:post>
<choose:get>
Select a file to upload: <ul:file_upload></ul:file_upload><br >
<input type="submit" value="Upload File">
</choose:get>
</lift:snippet>
The idea is that when a user hits the page for the first time (i.e. a GET request), then Lift will show the form for uploading a file. When the user submits the form (i.e. a POST request to the same page), then Lift instead displays the outcome of the file being processed.
With my application, the new wrinkle is that my "results" POST view needs to also contain a form. I want to provide a text input for the user to enter an email address, and a submit button that when pressed will email information about the processed file:
...
<choose:post>
<p>
File name: <ul:file_name></ul:file_name><br >
MIME Type: <ul:mime_type></ul:mime_type><br >
File length: <ul:length></ul:length><br >
MD5 Hash: <ul:md5></ul:md5><br >
</p>
<!-- BEGIN NEW STUFF -->
Output: <br/>
<textarea rows="30" cols="100"><ul:output></ul:output></textarea>
<br/><br/>
Email the above output to this email address:<br/>
<ul:email/><br/>
<input type="submit" value="Email"/>
<!-- END NEW STUFF -->
</choose:post>
...
However, both the GET and POST versions of this page are wrapped by the same Lift-generated form, which has its "action" set to the same snippet in both cases. How can I change this such that in the POST version, the form's action changes to a different snippet?
In a typical web framework, I would approach something like this with an "onclick" event and two basic lines of JavaScript. However, I haven't even begun to wrap my mind around Lift's... err, interesting notions about writing JavaScript in Scala. Maybe I need to go down that route, or maybe there's a better approach altogether.
First, I will suggest you use Lift's new designer friendly CSS binding instead of the custom XHTML tag.
And one thing you should remember when you're using Lift's snippet, is that it is recursive, you could put an lift snippet inside another snippet's HTML block.
For example, if you wish there is another form after POST, then just put it into the block.
<choose:post>
<p>
File name: <ul:file_name></ul:file_name><br >
MIME Type: <ul:mime_type></ul:mime_type><br >
File length: <ul:length></ul:length><br >
MD5 Hash: <ul:md5></ul:md5><br >
</p>
<!--
The following is same as <lift:snippet type="EMailForm" form="post" multipart="true">
-->
<form action="" method="post" data-lift="EMailForm">
<input type="text" name="email"/>
<input type="submit" />
</form>
</choose:post>
Then deal with the email form action at snippet class EMailForm.
Finally, you may pass the filename / minetype and other information by using hidden form element or SessionVar.
I agree with Brian, use Lift's new designer friendly CSS binding.
Use two separate forms, one for the file upload and one for the submitting the email. Use S.seeOther to redirect the user to the second form when the first has finished processing.
I also prefer the new 'data-lift' HTML attribute.
File upload HTML:
<div data-lift="uploadSnippet?form=post">
<input type="file" id="filename" />
<input type="submit" id="submit" />
</div
File upload snippet:
class uploadSnippet {
def processUpload = {
// do your processing
....
if (success)
S.seeOther("/getemail")
// if processing fails, just allow this method to exit to re-render your
// file upload form
}
def render = {
"#filename" #> SHtml.fileUpload(...) &
"#submit" #> SHtml.submit("Upload", processUpload _ )
}
}
GetEmail HTML:
<div data-lift="getEmailSnippet?form=post">
<input type="text" id="email" />
<input type="submit" id="submit" />
</div
Get Email Snippet:
class getEmailSnippet {
def processSubmit = {
....
}
def render = {
"#email" #> SHtml.text(...) &
"#submit" #> SHtml.submit("Upload", processSubmit _ )
}
There's a bit more on form processing in my blog post on using RequestVar's here:
http://tech.damianhelme.com/understanding-lifts-requestvars
Let me know if you want more detail.
Hope that's useful
Cheers
Damian
If somebody comes up with a more elegant (or "Lift-y") approach within the next few days, then I'll accept their answer. However, I came up with a workaround approach on my own.
I kept the current layout, where the view has a GET block and a POST block both submitting to the same snippet function. The snippet function still has an if-else block, handling each request differently depending on whether it's a GET or POST.
However, now I also have a secondary if-else block inside of the POST's block. This inner if-else looks at the name of the submit button that was clicked. If the submit button was the one for uploading a file, then the snippet handles the uploading and processing of the file. Otherwise, if it was the send email submit button shown after the first POST, then the snippet processes the sending of the email.
Not particularly glamorous, but it works just fine.