# .asp file problem



## GSquadron (Apr 3, 2011)

Hi guys!
I am trying to do a site as a homework, but i got "trapped" with the submitting button.
It clearly says that if you type your name, it will go to the index.asp file, but i see nothing
there and the file index.asp stays 0 bytes :S
Anyone can help me with this?


----------



## Disparia (Apr 3, 2011)

Post the code please.


----------



## Kreij (Apr 3, 2011)

Jizzler's right, Alek, without seeing the code we have no idea what's going on.


----------



## GSquadron (Apr 3, 2011)

ok, here is the code:
<form name="input" action="Index.asp" method="get">
Username: <input type="text" name="user" />
<input type="submit" value="Submit" />
Now the information goes to the .asp file in the same folder
but i dont see anything in the file  and it is 0 bytes, meaning there is nothing in it


----------



## Disparia (Apr 3, 2011)

GET/POST data is not writen to the file, it is accessible though. On your Index.asp page, you would have something like this at the top:


```
<%
Dim name
name = Request.Form("name")
%>
```

Then the name variable could be used on that page.


----------



## GSquadron (Apr 3, 2011)

I got nothing man
I dont know if you tried the code, but it doesn't happen anything to me
Should i add the code you gave? If yes where?
How can i make it to write the data?
method="post"????


----------



## Disparia (Apr 3, 2011)

Sorry, just noticed now that your form method is GET. To get those values you'd use Request.QueryString(_Name_Of_Form_Element_).

If you change your form's method to POST, then you would access the the data with Request.Form(_Name_Of_Form_Element_).

This might help demonstrate it:


```
<html>
<body>
<form action="getdemo.asp" method="get">
Your name: <input type="text" name="name" />
<input type="submit" value="Submit" />
</form>
<%
dim theName
theName = Request.QueryString("name")
IF theName <> "" THEN
	Response.Write("Hello " & theName)
ELSE
	Response.Write("Hello Anon!")
End If
%>
</body>
</html>
```

Put it into a file, save as getdemo.asp, run it. (and hopefully it works, I do about 1000 times more scripting in PHP than ASP).


----------



## GSquadron (Apr 3, 2011)

THANKS MAN!
you made my day!
I will give it a try and reply if i have any problems 

EDIT: Ok, i edited the html file and added your demonstration, same thing again
than i created a new file .asp and pasted the demonstration, " again
than i deleted the first html edit and did same think again, nothing
Can you show me were to put the demonstration exactly? I think i am missing smth here


----------



## Disparia (Apr 4, 2011)

I just tried it, no problems.

Is your server set up correctly? Apache needs a seperate module installed to handle ASP. For learning purposes, using IIS with it's native support for ASP would be easiest.


----------



## GSquadron (Apr 4, 2011)

Ok. So now i got smth new! I know what is apache server i have it installed, but i have never used it. How is the process? Should i write the code in apache or in notepad?
Simply i dont know what should i do with the apache program.
I have installed Easy php which has the apache program.


----------



## Deleted member 3 (Apr 4, 2011)

Aleksander Dishnica said:


> Ok. So now i got smth new! I know what is apache server i have it installed, but i have never used it. How is the process? Should i write the code in apache or in notepad?
> Simply i dont know what should i do with the apache program.
> I have installed Easy php which has the apache program.



What exactly is your homework? First you mention ASP, apparently you installed PHP though. Doesn't your teacher tell you what to use?


----------



## streetfighter 2 (Apr 4, 2011)

I'm just pointing out that nothing in this thread makes sense. 

I'm chalking that up to Aleksander having to write in a foreign language, which is completely understandable.


DanTheBanjoman said:


> What exactly is your homework? First you mention ASP, apparently you installed PHP though. Doesn't your teacher tell you what to use?


This.

Apache doesn't even support ASP or ASP.NET out of the box but you can add support for it with mono (for ASP.NET).  I dunno much about original ASP because it's more or less abandoned.

If you're interested I wrote a guide on setting up LAMP in a VM which has support for C# & VB ASP.NET.  It's majorly overkill for what you're doing though. . .

Does the HW have to be done in ASP?  Can you do it in PHP?


----------



## GSquadron (Apr 4, 2011)

My homework is this:
1. Create a box where you can write your name
2. Create a button where the person who wrote the name, can register
3. The registration name, comes to a text page where i can see the name of the person
from the server
This is all guys! 2 days still not solved 
Now the file jizzler gave me, where should it be written????


----------



## GSquadron (Apr 4, 2011)

Bump!
PLS help me! plssssssssssss


----------



## streetfighter 2 (Apr 4, 2011)

So what language are you writing this thing in?



Aleksander Dishnica said:


> 1. Create a box where you can write your name
> 2. Create a button where the person who wrote the name, can register
> 3. The registration name, comes to a text page where i can see the name of the person


1.  Easy.
2.  Is there anything special about "register" or is it just sending the name typed into the textbox to the server?
3.  When you talk about viewing the names, do you mean that the names of people who pressed "submit" are appended to a file which is stored on the server (and inaccessible to the web clients)?


----------



## GSquadron (Apr 4, 2011)

1. yes it is
2. sending the name typed into the textbox to the server
3. the names of people can be seen "only" by me (server)
I have written all things here in a notepad saved as html, or even as php or asp
Nothing happens
The file does not show any name!


----------



## Kreij (Apr 4, 2011)

He's writing it in HTML (ASP) as per post #4, but the other details are sketchy.
Apache server? IIS server? 
Are you using VS Web developer? Some other IDE?
Does the text file with the registrants name need to be in html format?
How is it going to be viewed?

In all honesty this is really easy to do, but we don't have enough information.
I think maybe it got over-engineered (we tend to do that here at TPU  ) and he just needs it to run on a simple IIS server.


----------



## GSquadron (Apr 4, 2011)

I am using Easy php
It has apache server integrated in the package
I dont know what is this apache, just have heard it has to do with servers
I am using Notepad as a program to make the web developing
The registrant names, need to be saved in a file, whatever it is, just to be read by me (server)
It is going to be viewed as real characters eg: Kreij and not 32kjd2o3 (computer language)
Show me your method if you know how to do it, but i dont get the names in the page
The page stays 0 bytes!
I mean: the developing file, accesses another file, like example.example
People open the developing file, with browsers. They write their names
Their names are sent to the other file and i can see their names, only by the other file!


----------



## streetfighter 2 (Apr 5, 2011)

Oy! 

The following are web servers:
IIS
Apache

The following are frameworks:
-ASP
-ASP.NET

The following are programming languages that run server side:
-PHP (mod_php on Apache)
-Perl (mod_perl on Apache)
-Python (mod_python on Apache)
-C# (ASP.NET) (mod_mono on Apache)
-VB (ASP.NET) (mod_mono on Apache)
-VBScript (ASP)
-JScript (ASP)
-PerlScript (ASP)

The following are programming languages that run client side:
-JavaScript
-HTML
-CSS
(The three are sometimes referred to as DHTML)

EasyPHP is called EasyPHP because it uses PHP, not ASP and not ASP.NET.  If you want to use ASP or ASP.NET you'll have to use a web server that supports it such as IIS or Apache with mod_mono.



Aleksander Dishnica said:


> It is going to be viewed as real characters eg: Kreij and not 32kjd2o3 (computer language)


"Computer language" is the same as "real characters", it's just a different way of displaying them.  For instance all of the following are equivalent:


ASCII: |Kreij
HEX: |0x 004B 7265 696A
UNICODE: |0x 0075 0114 0101 0105 0106


Aleksander Dishnica said:


> I am using Notepad as a program to make the web developing


Notepad is terrible for writing code.  If you want something simple try Notepad++.


----------



## GSquadron (Apr 6, 2011)

Thanks for information man, but that didn't solve anything.
I have to complete it for tomorrow but i think none will help me.
I will give one last try though, not to blame myself for it
Ok, Jizzler wrote the code! Where to write all that code?
asp? php? html? VB? JavaScript?
Where to put it?????
What should i do! None gives answers here?
I just got in a stupid problem, i know the code
He is writing in html(asp)??? what is this logic?


----------



## streetfighter 2 (Apr 6, 2011)

Building on the Jizzler's example:

```
<html>
<body>
<form action="getdemo.asp" method="get">
Your name: <input type="text" name="name" />
<input type="submit" value="Submit" />
</form>
<%
dim theName
theName = Request.QueryString("name")
IF theName <> "" THEN
	set fso = Server.CreateObject("scripting.FileSystemObject")
	set f = fso.GetFile("..\names.txt")
	set ts = f.OpenAsTextStream(8, -2)
	ts.WriteLine(theName)
	f.Close
End If
%>
</body>
</html>
```
The code is going to be a combination of HTML and ASP.  The "<% . . . %>" section means you are using ASP; everywhere else is HTML. Since I didn't specify a language for the ASP section, it's assumed to be VBScript.

Save the code as "getdemo.asp" and create a blank file called "names.txt" in the nearest subdirectory to "getdemo.asp".  You will have NO WAY OF TESTING THIS unless you install a server that runs ASP . . .

Also, I've never wrote anything in ASP so I dunno if it'll work at all.


----------



## GSquadron (Apr 6, 2011)

Thanks man!
But that is again wrong
I can test by sending the name myself
The name didnt go
so there must be a mistake here for sure
I also tried in saving as getdemo.vbs, still didnt change a thing


----------



## streetfighter 2 (Apr 6, 2011)

Oy!  I'm not getting through to you . . .

Let's look at the code one more time.  Here's the HTML part:

```
<html>
<body>
<form action="getdemo.asp" method="get">
Your name: <input type="text" name="name" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
```
If you copy it to a file and save it with the ".html" extension it'll look good in your browser, but it won't be functional

*Why not?*
Because all of the HTML is being run on the client side, the server is doing no processing other than providing the data you've requested.

So if you add the following to the previous HTML:

```
<%
dim theName
theName = Request.QueryString("name")
IF theName <> "" THEN
	set fso = Server.CreateObject("scripting.FileSystemObject")
	set f = fso.GetFile("..\names.txt")
	set ts = f.OpenAsTextStream(8, -2)
	ts.WriteLine(theName)
	f.Close
End If
%>
```
Then save it as ".asp" and again try it, NOTHING HAPPENS.

*Why does nothing happen?*
Because the ASP code must be executed on the server, the server DOES NOT EXIST so the code is never executed.  Your browser will see the ASP code and do nothing because it cannot be processed client side.

*How do we fix it?*
Install IIS.  And make sure your ".asp" and ".html" files are added to the "Inetpub\wwwroot" directory.  Then open your server by browsing to "http://localhost/mypage.asp".


----------

