Problem with viewing submitted data in an HTML form in ASP - html

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!

Related

What is "mailto:someone#example.com" in following HTML form example?

I am learning HTML from w3schools HTML Tutorial - The Best in Class Tutorial
I come across one HTML form example which sends an email.
Please note that currently neither do I nor w3schools is going for server side input processing, so you also don't think about server side processing while considering my question.
Below is the code of HTML example :
<!DOCTYPE html>
<html>
<body>
<h2>Send e-mail to someone#example.com:</h2>
<form action="mailto:someone#example.com" method="post" enctype="text/plain">
Name:<br>
<input type="text" name="name"><br>
E-mail:<br>
<input type="text" name="mail"><br>
Comment:<br>
<input type="text" name="comment" size="50"><br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>
</body>
</html>
Normally I see a .php or .asp filename in action attribute of a form but in above example it's mailto:someone#example.com.
I want to know what is it and why they have not used a .php or .asp file-name as they normally do?
Please someone explain me.
Thank You.
You are basically giving the users browser the job of handling the mailto request. The browser usually starts the users mail client and fills in the fields according to the input of your form.

Submit of simple HTML form with get method fails to construct URL with params

I have the following simple HTML:
<!doctype html public "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Foo</title>
<body>
<form method="get" action="http://example.com">
<input type="hidden" id="go">
<div>
<label for="userid">Userid:</label>
<input type="text" id="userid">
</div>
<div>
<input type="submit" value="Login">
</div>
</form>
</body>
</html>
I validated this with W3C's online validator: all that it doesn't like is the hidden input element not being inside a div, p or some such.
When this page is loaded and the form is filled and submitted, it goes to the exact URL http://example.com, without any form parameters.
This happens whether I serve it as a static page from a server, output it out of a CGI script or access it as a local document using file://... on my desktop box. The behavior is the same using Firefox 43.0.4 on Windows 7, IE 11, or FF 42.0 on Ubuntu 12.
What is missing to make it produce something like http://example.com?go&userid=whatever?
You haven't use name attributes in input fields.

Form action relative URL

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 !

working with forms in HTML 5

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>

HTML form submission across various pages

I have 4 HTML Pages. In each page I have forms and form elements, but my submit button is only in my 4th page. So how do i try to access the elements i selected in the first three pages without using JavaScript??
For Eg: Consider a feedback form where we have to answer question in 3-4 pages in order to submit the feedback. We click "Submit Feedback" button only in the 4th page so how do the elements from the 1st, 2nd and the 3rd page get submitted to the server??
THIS IS A PROBLEM SHEET FROM MY COLLEGE. HERE IS THE FULL QUESTION
Step 1:
Identify a web architecture that is suitable for a survey website. The survey website will start with a brief introduction about the survey, and followed by the survey questions. Each question webpage will contain at most two survey questions, links to previous and next questions and a test submit button. Note that a server script is created for this lab allowing you to test if data are correctly passed to the server when the ‘Test’ button is clicked. However, no data will be saved at the server.
Step 2:
Use any text editor on your local computer (e.g. NotePad++), create the HTML for the survey website that contains the following HTML 5 elements. The survey form will be placed between the ... tags.
<!DOCTYPE HTML> <html lang="en"> <head>
<meta charset="utf-8"> <meta name="description" content="Web development">
<meta name="keywords" content="HTML (Part 1 – Content - Form)">
<meta name="author" content="put your name here">
<title>Web Development Survey</title>
</head> <body>
<!–- Survey content --> </body>
</html>
Step 3:
Mark up the form content using the elements discussed in Lecture 3. These are
- Form <form> ... </form>
- Form elements such as <label>...</label>, <input ...>, <select> ... </select>, <text area> ... </text area>,<fieldset> ... </fieldset> and <legend>...</legend>
Use other HTML elements discussed in Lecture 2 as needed
- Heading <h#>...</h#>, Paragraph <p>..</p>, Horizontal Rule <hr>
- List <ol>...</ol> or <ul>...</ul>, Table <table>...</table>, Image <img ...> and Anchor <a ... >...</a>
- Special characters
For instance the first question page for the name and sex can be marked up as follows.
<form id="survey" method="post" action="http://mercury.ict.swin.edu.au/cchua/webdev/surveytest.php">
<p><label>Name (optional)</label> <input type="text" name="name" size="20" />
</p> <p>Gender<br />
<label>Male</label> <input type="radio" name="gender" value=”M" />
<label>Female</label>
<input type="radio" name="gender" value="F" /> </p>
<p><input type="submit" value="Test" /> <input type="reset" value="Reset" />
</p>
</form>
Note that XHTML coding style is used in the above sample code
A processing script had been set up at the server with the following URL:
"//mercury.ict.swin.edu.au/cchua/webdev/surveytest.php"
This allows you to test if your form can correctly pass the inputted data to the server. Note that none of the sample data entered will be saved at the server.
You can obtain all the survey information and question at surveydata.txt. Ensure that correct form elements are used for each survey question. For example, checkbox is use for questions that allows multiple answers, while radio button is used for single choice questions.
Step 4:
Create a new folder ‘lab03’ under the unit folder on the mercury server ~/hit1091/www/htdocs. Upload today’s work to this lab03 folder.
Using WinSCP, drag and drop the all the survey HTML files from your local machine to the htdocs/lab03 folder. You can name the survey HTML files using the ‘survey##.htm’ format where ## represent a 2-digit number. For example, the first page can be named as ‘survey01.htm’ and so on.
Step 5: Test and view web pages.
To view the pages through http, use any Web browser and type in the following address,
//mercury.ict.swin.edu.au/hit1091//
The is s< your 7-digit Swinburne ID >. For example
*http://mercury.ict.swin.edu.au/hit1091/s1234567/lab_03/survey01.htm*
When the authorization request dialog pops up, use your SIMS username and password to confirm access.
Step 6: Validate the page(s) and fix any errors displayed and revalidate
To validate HTML file, use the ‘File Upload’ interface at http://validator.w3.org. For webpages pages that requires server pre-processing, validation via ‘URL’ must be used
What you need to do is to submit on every page. Then through some server-side scripting attach the post to the form in your next page until you are ready to process the information.
For example, if you were doing this in PHP you could have something like this on your second page.
<form method="post" action="page-3.html">
<label>Input for page 2</label>
<input type="text" name="page2Input" />
<?php
foreach($_POST as $key => $value) {
echo '<input type="hidden" name="'. $key .'" value="' . $value .'" >'; //Info from page 1
}
?>
<input type="submit" value="To Page 3">
</form>
This will "add" the information from first page into the form for its information to also be send to page 3. Or you could also just put them in a $_SESSION.
There are different ways to do it. This is just one of them. Don't forget to sanitize your input though.