Hey,
I was hoping you folks could shed some insight onto parsing data from
HTML forms in my webapp (written in Sinatra and Sequel). I'm
relatively new to HTML, but I understand that once you enter data into
the form and submit it, you're redirected to an .asp page. My plan
afterwards is to somehow parse the URL from the page you're redirected
to and extract the form data from it. This seems like a clunky
solution, but I haven't been able to find anything else promising
online. Here's the code I've written, if I'm being unclear:
<form name="add_person_form_name" method="get"
action="add_to_db_form.asp" method="get">
Type your first name here:
<input type="text" name="fname_form" size="20"><br>
Type your last name here:
<input type="text" name="lname_form" size="20"><br>
Type your current town here:
<input type="text" name="town_form" size="20"><br>
Now, say the magic word...<br>
<input type="submit" value="Please">
</form>
Let's say the user is named John Doe and lives in Chicago... once the
user fills in their data and presses "Please," they are redirected to
http://localhost:4567/add_to_db_form.asp?fname_form=John&lname_form=Doe&town_form=Chicago.
I can make a get-routine to tell Sinatra what to do when this happens,
but I don't know how to intercept the URL and parse it.
I suppose my main question is, am I taking the right approach for
this? Is there an easier way to get data from the user with HTML
forms and Sinatra (and Sequel, although I know this isn't the right
board to ask about Sequel)? Something tells me there has to be a much
easier way, but I haven't found anything relevant online. If I am
taking the right approach, how do I parse through the URL? In
addition, how would I check for buffer overflows or SQL injection when
using these kinds of forms?