i have tried the following code while trying to learn html forms:
<head>
<title>Example</title>
</head>
<body>
<form method="post" action="http://titan:8080/form">
<input name="fave"/>
<input name="name"/>
<button>Submit Vote</button>
</form>
</body>
but its not working the webpage shows this message: "Oops! Google Chrome could not find titan:8080"
The action attribute must contain a valid URL. In this case, the server part of the URL is not valid, since titan is not a valid domain name. It should be something like titan.example or titan.foobar.example.com (naturally, you need to use the real, working domain name; the names I used are guaranteed to not work, i.e. for use as dummy examples only).
Alternatively, if you are running a local HTTP server, at port 8080, in the computer where you use the HTML page, use the reserved name localhost as in action="http://localhost:8080/form">.
The url you have provided http://titan:8080/form is timing out ensure you have the correct url or that the page is live.
<title>Example</title>
<form method="post" action="#a">
<input name="fave"/>
<input name="name"/>
<button>Submit Vote</button>
</form>
Related
I wrote this HTML form and I'm trying to process it in asp using POST, so that as soon as I submit the form, it should show the data that I submitted in the HTML form.
The HTML form works fine, but whenever I click on submit, It doesn't show what I've submitted, it just shows the ASP code that I wrote. I don't know what I'm doing wrong. anyone got an idea?
This is my HTML code
<!DOCTYPE html>
<html>
<head>
<title>HTML Forms!</title>
<link href="buy.css" type="text/css" rel="stylesheet" />
</head>
<body>
<h2>Give Us Your Money</h2>
<form method="post" action="validate-ex2.asp">
First Name: <input type="text" name="fname"><br><br>
Card Number: <input type="text" name="cnumber"><br><br>
<legend>Credit cards:</legend>
<input type="radio" name="cc" value="visa" checked="checked" /> Visa
<input type="radio" name="cc" value="mastercard" /> MasterCard
<br><br>
<input type="submit" value="Submit"> <br>
</form>
</body>
</html>
And this is my ASP code
<html>
<body>
<%
dim fname
fname=Request.Form("fname")
Response.Write("First Name: " & fname & "<br>")
%>
</body>
</html>
I tried everything here, here and here but still same error, I hope I haven't messed up anything by doing what was described there
EDIT: Here's an image of the output while trying to run a simple HTML code that includes ASP-classic Trying to run ASP
Apparently I had to move my ASP and HTML file to the C:\inetpub\wwwroot\ folder, but not only this. I tried running them from there as well, but still it would show the raw code. what I did first, was enabling other Windows Features (that I saw somewhere online).
This actually could've been the fix from the beginning but running the html or the asp code directly from the C:\inetpub\wwwroot\ shows the raw ASP code, I just had to type localhost/[filename].html or whatever in the browser and also modifying the permissions by adding Everyone and allowing full control and modify to the folder inside inetpub or the files themselves...
Sorry if you guys thought I was doing that from the beginning, but now it works just fine. Thanks for your help!
possibly a stupid question but how do I upload files to a server using the browser ?
I'm sure I've used this before ! But when I run it nothing appears to happen.
No errors are shown and nothing is logged in the error_log
<?php
var_dump($_FILES);
echo $_FILES['uploadFile']['tmp_name'];
?>
<html>
<head>
<title>File Upload Form</title>
</head>
<body>
This form allows you to upload a file to the server.<br>
<form action="test.php" method="post"><br>
Type (or select) Filename: <input type="file" name="uploadFile">
<input type="submit" value="Upload File">
</form>
</body>
</html>
What am I doing wrong ?
When you submit a form, the data you are sending to be encoded somehow to be put in the HTTP request.
By default, this uses the application/x-www-form-urlencoded algorithm which does not support file uploads. You need to use multipart/form-data instead.
<form action="test.php" method="post" enctype="multipart/form-data">
Try to correct you form declaration attribute and always when you need to upload files include "enctype". If not file input element is in form, the default enctype is "application/x-www-form-urlencoded":
<form action="test.php" method="post" enctype="multipart/form-data">
FORM in HTML
I am trying to allow users on my website to upload an image with a form.
I have been using formspree (https://formspree.io/)
I receive the name of the image but no image attached to the email.
I'm using:
<label>
Upload Photo
<input type="file" name="uploadField" />
</label>
Has anyone managed to do this?
Formspree currently doesn't support file inputs, but Formsprees FAQ has this advice:
For almost zero work and cheap (or free) prices you can integrate external file upload services into a Formspree form. Uploadcare is one example. If you just create an account and include their widget:
<!-- The best place for this one is your <HEAD> tag -->
<script>UPLOADCARE_PUBLIC_KEY = "demopublickey";</script>
<script
src="https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js"
charset="utf-8"></script>
<!-- This is where the widget will be. Don't forget the name attribute! -->
<input type="hidden" role="uploadcare-uploader" name="my_file" />
Per their documentation, you can use that inside the Formspree form and receive the URL of the document in your email address.
Source: https://help.formspree.io/articles/6199-how-to-do-file-uploads-with-formspree
I'm pretty sure the issue is your enctype isn't defined. Here's an example using a basic HTML form (you'll need some PHP/server side code to process the file):
<form action="your_script.php" method="post" enctype="multipart/form-data">
Image: <input type="file" name="uploadField" />
<input type="submit" value="Submit">
</form>
I have html file like this:
<!DOCTYPE html>
<html>
<head>
<title>HTML Form</title>
</head>
<body>
</body>
</html>
<FORM action="/wsd/html_form_check" method="post">
<P>
//INPUTS AND LABES AND THINGS
<INPUT type="submit" value="Send">
</P>
</FORM>
Now I get an error saying
AssertionError: Invalid form action.
I suppose it has something to do with the
<FORM action="/wsd/html_form_check" method="post">
I was told that the HTTP request should look like this:
POST /wsd/html_form_check HTTP/1.1
Host: 127.0.0.1
So what am I doing wrong? Any help is appreciated!
Thanks!
A bit late, but I had to deal with the same issue.
Consider the following piece of HTML code:
<form id="file_uploader" action="/Home/Upload" class="dropzone">
<div class="fallback">
<input name="file" type="file" multiple />
</div>
</form>
In the development environment it runs fine. However, deploying it to IIS anywhere else but the root website will cause the action URL to become invalid. For instance, if it were deployed to https://example.com/deployed_app, then the actual action URL that the form will call is https://example.com/Home/Upload, which is invalid.
The solution is to change the action URL to this:
<form id="file_uploader" action="~/Home/Upload" class="dropzone">
If you're trying to send the data entered in the form to "html_form_check" you haven't used the file extension such as .php or .js. Try adding the file extension and see if that helps !
How can I change the messages of HTML5 (or doses it change according to browser's language automatically?)
For example:
<!DOCTYPE HTML>
<html>
<body>
<form action="demo_form.asp" method="get">
E-mail: <input type="email" name="user_email" /><br />
<input type="submit" />
</form>
</body>
</html>
When I run this code (from W3schools) at Opera and write a non valid e-mail address it says
Please enter a valid email address
How can I change it to another language instead of English or change the warning to what I want?
Well there are different options.
You can disable the form validation of the form (or the field) with formnovalidate and provide a custom error message with javascript (and serverside ofcourse).
You can use javascript and use the .setCustomValidity() method to provide a (custom) error message but it is intended to add extra rules to the field.
You can use x-moz-errormessage to set a custom errormessage. But using this you need to know that this is not a standard.
There are no built-in internationalisation solutions currently in HTML(5) and all proposals seem dead. However you may find the Passive Localisation JavaScript library of some use. Online demonstration can be found here.