September 20th, 2013, 12:17 PM
Asp - post form data to a new page
On page 1, I have a form, which onclick="location.reload(); the same page and runs a classic asp validation scrip. If the validation passes (fields filled in and no duplicates found ect), how do I then post this form data to page 2 where it can then be added to the db.
// test to see if its a bot
If Request("test") = "" Then
// if its NOT a bot then...
If Request("username") = "" Then
username = Server.HTMLEncode(Request.Form("username"))
strSQL = "SELECT username FROM Owner WHERE username = '"+username+"' "
Set rs_username = conn.Execute(strSQL)
If rs_username.EOF Then
//No record exists, move onto error checking and form submission
// Record exists, Display alert, do nothing
End If // end rs_username.EOF
End If // end if username
End If // end test
<form action="" method="post" name="form1" onclick="location.reload();location.href='page1.asp'>
<input name="test" type="hidden"><br>
user <input name="username" type="text"><br>
fN<input name="firstname" type="text"><br>
<input type="submit" value="Submit Form" name="submit">
September 20th, 2013, 06:08 PM
Have you checked that it does send the correct values?
Reload does not send, but let the user re-retrieve the page before he entered anything.
You should use the 'action' parameter to send the information.
Can see the ASP code on that page only check if the user name exists before it forward the reloaded (empty?) form to page2.asp.
You still have to validate all user input at that page - page2.asp, which mean this scripts seems to be complete unnecessary (calling it useless will be to harsh ).
You should also look up SQL injection. Inserting user input directly into a SQL statement is an open invitation to let other people calling their own SQL command.