How to send a post request to GTMetrix - html

I want my users to write his website on my site and then be sent to gtmetrix.com to start a new test, but without needing to write his website again.
I am trying with this:
<form method="post" action="https://gtmetrix.com/analyze.html">
<input type="text" placeholder="Enter your Website URL"></input>
<input type="submit">CHECK IT</input>
</form>
But i get a
Analysis Error
You tried to analyze an invalid/malformed URL
What i am doing wrong? is possible to do this?

It seems they require the url in the form data field called url.
You must use the following input tag:
<input type="url" name="url" value="" placeholder="Enter your website URL" maxlength="1024" autofocus="" required="">
Also, they could be blocking external referrers. But first try adding the name attribute.

First of all, I don't know if that website allows you to submit that form from external websites. Make sure that's possible!
Seccond of all, you are trying to sent a form without setting the name of the input field. The resource that receives your request don't know anything to do with it.
If you want to analyse websites on your own website, search for services that provide APIs for using it external.

I am not familiar with gtmetrix, but you need to set the name attribute on your input to send it with the request.

Related

How to submit HTML form into a Sheet?

I've checked around and most things I've found are from 2012 and workarounds for a then-existent bug. Unfortunately I'm not understanding Google's documentation on this very well.
I have a script project that is serving a web page to visitors with an HTML form:
<form id="gradingform">
<input type="text" name="name" placeholder="Name">
<input type="number" name="grade" placeholder"100">
<input type="submit" onclick="<this is where I'm having issues>">
</form>
I believe that this needs to be handled like any other time getting a script while serving a web page - by using the google.script.run. With a form specifically, I think that it's supposed to be using a success handler, so for example, something along the lines of
google.script.run.withSuccessHandler(gradeSubmitted).recordGrades()
gradeSubmitted() would be a function that just dispays a message, easy enough by doing some easy div changing. What my real issue is what recordGrades() would be like.
How do I pass the form to this function, and how do I collect the information from the form? From there I will be adding it to a Sheet, which is easy enough once the information is in an array because I can just append it. The documents say the form information should be passed as a Blob, but Google's example is kind of confusing.
This is what you have to do
onclick="google.script.run.withSuccessHandler(gradeSubmitted).recordGrades(this.form)"
And in the code.gs file you will be receiving a json as
[16-03-25 10:51:51:046 IST] {grade=10, name=Anees}

Proper HTML markup and authentication flow for password manager compatibility?

I'm working on a webapp written in angular that seems to have trouble interacting with the various password managers (Dashlane, LastPass, etc) that are out there. Are there any guidelines around HTML markup and authentication flow to ensure compatibility? This is not just for login flow, but also includes things like password reset, user name changes, and so on.
It appears that this question has already been asked, but not in the context of AngularJS.
From https://lastpass.com/support.php?cmd=showfaq&id=3385
While LastPass can work on most website logins, if you are developing your own site you can help make it LastPass-compatible by using a simple form submit with a username, password, and submit field.
Here's an example:
<form action="https://mypage.com/blah" method="post">
<input type="text" name="username" id="username" value=""/>
<input type="password" name="password" id="password" value=""/>
<input type="submit" value="LOGIN"/>
</form>
As far as what to avoid -- always create the form on page load, even if you hide and show it to people clicking log in, it's better to be there on page load. Avoid ajax for logging in and avoid method=GET
So besides giving name attributes to your controls, LastPass recommends having the login form markup already in the HTML when it is first loaded.

Beginner in html and objective-c, nsurlconnection and html values

I'm currently working with objective-c and have run in to a problem concerning javascript. I am connecting to a website through an iphone app and my goal is to login to a html form (Login.jsp)
<label class="login_label">Username</label>
<input autocomplete="off" type="text" value="" name="ssusername" size="20" maxlength="50" />
<label class="login_label">Password</label>
<input autocomplete="off" type="password" name="sspassword" size="20" maxlength="20" value=""/>
I am trying to make a NSUrlConnection to this site in objective-c but the concern is this: If I enter
https://www.login.com/Login.jsp?ssusername=%#&sspassword=%#, username.text, password.text
It will only enter the enter the password in the html form. And when I look at the javascript I suspect it has something to do with the value in the username html code being value=""
My question: Is it possible to, without changing the html code (as I don't have access to it) make a NSUrlConnection passing username and password and retrieving the answer from this html form, or if anyone know why the username wont show when the adress is entered as above?
I think, login method may use POST method and your NSURLConnection is using get method.
You can check at POST with NSURLConnection - NO JSON.
It depends on server side. You can't really change input field value via GET parameters -- it's server-side job.
You can execute JS code to enter username and password and then click login button via UIWebView's stringByEvaluatingJavaScriptFromString function or you can check this site/server documentation for some authentication methods and then use them (like #saturngod suggested).

How do I make a simple email form submission in HTML?

I tried w3schools but it didn't help and I tried other websites too. I just wanna make a short html script that sends an email to an email address, but I keep reloading my email inbox and nothing comes up. Can you help?
<form action="MAILTO:MY_EMAIL#yahoo.com" method="post" enctype="text/plain">
<input type="text" name="email" value="Email">
<input type="text" name="message" value="Message">
<input value="Submit" type="submit">
</form>
You need to use a server side script here. HTML alone won't help you here. HTML is just the frontend logic. You need some script on backend that accepts this data you submit and actually sends out an email. To take the example in PHP, assuming u have the server set up and all or that your shared
<form action="sendmail.php" method="post" enctype="text/plain">
<input type="text" name="email" value="Email">
<input type="text" name="message" value="Message">
<input value="Submit" type="submit">
</form>
sendmail.php
$email=$_POST['email'];
$message=json_encode($_POST);
$receiver="MY_EMAIL#yahoo.com";
$mailer="mailer#myservice.com";
mail($email,"Message for enquiry or whatever",$message, array("from"=>$mailer));
There were, at some point, browsers that supported forms of this type. However, they're all gone now -- you will need a server-side script to send email. It's impossible to do using HTML alone.
You are confusing a few things.
When you Submit a form, it goes from the client (browser) to your server, which acts upon it. The form action needs to be a URL which handles the request. The mailto: URI scheme is not a valid action to use.
You have two choices:
You can create a mailto: link like this:
Send email
which will open your default email client,
OR
You can put a URL corresponding to an end point on your server, something like
form action="/send/mail"...
and have your server send the email
I believe the easiest way to do this is using a service like Zapier or IFTTT. Both of them offer a way to create Zaps/Applets that can send an email when you post to a specific url.
This is what configuration would look like in IFTTT and Zapier .
IFTTT is simpler to setup, Zapier has more options, like sending to more than one emails. I believe IFTTT only lets you send to your account's email.

How to use the form value in the action?

I am trying to make a form in html that uses the value you enter to form the destination URL.
<form action="../search/${params.q}" method="post" id="q">
Busqueda: <input type="text" name="q" /><br />
</form>
This is what i am doing, but it does not work, any cluess? thanks!
You'd need to handle this using a script - either server-side or on the client (JavaScript).
HTML alone can't handle parameters in the way you're using them.
So you'd need to either POST the form (as you're already doing) and handle the postback by redirecting your request to the new address, or use JavaScript to capture the field's value when a submit button is clicked and loading the new address in the browser window.
I'd suggest server-side is the best option as JavaScript might be disabled or unavailable.