Hi all,
I got a small problem. I created a form and when I press the submit button it should show a message, the message isn't showing:
Code:
<%
file = Request.QueryString("file")
if file = "" THEN
Response.Write "You followed an invalid link"
elseif file = file THEN
sql = "SELECT * FROM DOCUMENT WHERE Document.[id]=("& file &")"
Set RS = Conn.Execute(sql)
%>
<html>
<body>
<form action="edit.asp?file=<%=file%>" name="bewerken" enctype="multipart/form-data" method="Post">
<table border="1">
<tr>
<td><input size="50" type="text" value="<%=rs("user_id")%>"></td>
</tr>
<tr>
<td><input size="50" type="text" value="<%=rs("desc")%>"></td>
</tr>
<tr>
<td><input size="50" type="text" value="<%=rs("filename")%>"></td>
</tr>
<tr>
<td><input size="50" type="text" value="<%=rs("department")%>"></td>
</tr>
<tr>
<td><input size="50" name="submit" type="submit" value="Edit" style="color: #FFFFFF; border: 1px solid #800000; padding-left: 1px; padding-right: 1px; padding-top: 0px; padding-bottom: 0px; background-color: #800000"></td>
</tr>
</table>
</body>
</html>
<%
End If
If Request.Form("submit")="submit" THEN
Response.Write "blaat"
End If
because the VALUE of your submit button is EDIT ... so your code should be:
Code:
If Request.Form("submit")="Edit" THEN
Response.Write "blaat"
End If
Was this answer helpful ?
Yes No
Okay, code modified but unfortunately still not working. It's still not displaying the text blaat
Was this answer helpful ?
Yes No
You should fetch the value of the submit button on your next page, the page where you submit form (edit.asp).
Furthermore, value of your submit button is 'Edit', not 'submit':
Code:
If Request.Form("submit")="Edit" THEN
Response.Write "blaat"
End If
Furthermore, you can't use querystring ?file=<%=file%> because this is POST method. You should create a hidden field instead:
<input type="hidden" name="file" value="<%=file%>">
Furthermore, you used enctype="multipart/form-data", I'm not sure you can use Request.Form.
Was this answer helpful ?
Yes No
Quote:
| Originally Posted by imbrod You should fetch the value of the submit button on your next page, the page where you submit form (edit.asp).
Furthermore, value of your submit button is 'Edit', not 'submit':
Code:
If Request.Form("submit")="Edit" THEN
Response.Write "blaat"
End If
Furthermore, you can't use querystring ?file=<%=file%> because this is POST method. You should create a hidden field instead:
<input type="hidden" name="file" value="<%=file%>">
Furthermore, you used enctype="multipart/form-data", I'm not sure you can use Request.Form. |
Isn't there a way to do it in the same file like in php :
if($_POST['submit']){
Was this answer helpful ?
Yes No
1. remove this from the from tag: enctype="multipart/form-data"
(it's used only when uploading files from client)
2. change this:
Code:
file = Request.QueryString("file")
to this:
Code:
file = Request.Form("file")
also, this line is meaningless:
Code:
elseif file = file THEN
it will always be true.
Was this answer helpful ?
Yes No
Quote:
| Originally Posted by olger901 Isn't there a way to do it in the same file like in php :
if($_POST['submit']){ |
if you're uploading file, look into "pure ASP upload" there is no simple way to upload
files in classic ASP, you'll have to use upload component or script.
Was this answer helpful ?
Yes No
Quote:
| Originally Posted by Shadow Wizard 1. remove this from the from tag: enctype="multipart/form-data"
(it's used only when uploading files from client)
2. change this:
Code:
file = Request.QueryString("file")
to this:
Code:
file = Request.Form("file")
also, this line is meaningless:
Code:
elseif file = file THEN
it will always be true. |
I tried but that didn't work.
If I do so it will always display You followed an invalid link
Unforunately I need to use file = Request.QueryString("file") because I am using a GET and this GET is given from the main page when I press the edit button with the id behind it, what you get to see is this page
Was this answer helpful ?
Yes No
ok, I see now - the page you posted is called from other page. you see the file id
passed on the querystring? if not, make sure you have such field in the previous page:
Code:
<input type="text" name="file" />
if this is <input type="file" /> html element, disregard all that has been said here and look
into "ASP Upload" tutorials - it's
not so simple as you might have thought.
Was this answer helpful ?
Yes No
Also - don't name the button submit.
Change
Code:
<td><input size="50" name="submit" type="submit" value="Edit" style="color: #FFFFFF; border: 1px solid #800000; padding-left: 1px; padding-right: 1px; padding-top: 0px; padding-bottom: 0px; background-color: #800000"></td>
to
Code:
<td><input size="50" name="submitButton" type="submit" value="Edit" style="color: #FFFFFF; border: 1px solid #800000; padding-left: 1px; padding-right: 1px; padding-top: 0px; padding-bottom: 0px; background-color: #800000"></td>
(It can be any name - just not submit)
Was this answer helpful ?
Yes No