Request.QueryString doesn't get the input names from html form - asp.net

I need to take the username, email and password a user enters in an html form (in index.aspx) and use it in an asp.net code in another page (register.aspx in a folder called 'u').
This is the form:
<form action="u/register.aspx" method="post" id="regForm">
<input type="text" name="fname" id="fname" placeholder="Full Name (Optional)" maxlength="16" />
<input type="text" name="uname" id="uname" placeholder="Username" maxlength="16" />
<input type="email" name="email" id="email" placeholder="Email Address" maxlength="32" />
<input type="password" name="pwd" id="pwd" placeholder="Password" maxlength="16" />
<input type="password" name="repwd" id="repwd" placeholder="Repeat Password" maxlength="16" />
<input type="submit" value="Sign Up" id="signup" />
</form>
But, when I'm using Request.QueryString["fname"] for example, it doesn't take 'fname' from the form, it just takes a null.
What can I do to solve this? Is there a different method I can use to achieve the wanted result?
Thanks a lot!

You are doing it wrong.
Request.QueryString contains information related to data added after ? in the URL (ex. http://www.contoso.com?mydata=1&param2=yy).
You have to use Request.Form to access "POST" data.

QueryString will only give the parameters on the query string of the url check here.
If you want all the parameters you will need to use the Params property.

As others have already said Request.QueryString contains data after the ? in url.
You can use Request.Form or if you want the data as part of the url, you can change your form element method attribute to "get"

Related

Create URL Query String to accept Terms & Conditions

I am building a script that is downloading a zip file and placing it on my desktop. The script works fine except the link to the zip file is taking me to a terms and condition site in order to download it.
I have the below form:
<form action="https://powhatan.iiie.disa.mil/TOUbanneraccept.asp">
<input name="HTTP_REFERER" type="hidden" value="http://iase.disa.mil/stigs/compilations/Pages/index.aspx">
<input name="HTTP_HOST" type="hidden" value="powhatan.iiie.disa.mil">
<input name="SERVER_NAME" type="hidden" value="powhatan.iiie.disa.mil">
<input name="URL" type="hidden" value="/TOUbanner.asp">
<input name="SCRIPT_NAME" type="hidden" value="/TOUbanner.asp">
<input name="PATH_INFO" type="hidden" value="/TOUbanner.asp">
<input name="Destination" type="hidden" value="">
<input name="OriginalURL" type="hidden" value="https://powhatan.iiie.disa.mil/stigs/downloads/zip/FOUO_SRG-STIG_Library_2017_04.zip">
<input name="RewriteURL" type="hidden" value="">
<input name="Accept" style="width: 150px;" type="submit" value="I ACCEPT">
</form>
I am trying to create a query string to accept the webpage terms so that my download will continue but my query string is not working. From what i researched I came up with:
https://powhatan.iiie.disa.mil/TOUbanneraccept.asp/?HTTP_REFERER=http://iase.disa.mil/stigs/compilations/Pages/index.aspx&HTTP_HOST=powhatan.iiie.disa.mil&SERVER_NAME=powhatan.iiie.disa.mil&URL=/TOUbanner.asp&SCRIPT_NAME=/TOUbanner.asp&OriginalURL=https://powhatan.iiie.disa.mil/stigs/downloads/zip/FOUO_SRG-STIG_Library_2017_04.zip&Accept=I%20ACCEPT
I even tried
https://powhatan.iiie.disa.mil/TOUbanneraccept.asp?Accept=I%20ACCEPT
When I try either one I get a Error 404 page as if the page does not exist. I have to do this because it will be included in a VBA macro.
Can anyone tell me what I am doing wrong or what may going on here?

Sending form data to another websites form

I am trying to incorporate a reservation widget within my wordpress install and I have everything working fine except sending the data or it not populating on the other sites form. The site I am trying to send data to is an online reservation software: http://www.directinn.com/demo/
Here is how I am doing my form:
<form name="bookingform" action="http://www.directinn.com/demo" method="get" target="_blank">
<input type="text" name="date1" id="Text1" class="ftxt MyDate three columns" maxlength="10" value="" placeholder="Arrival Date"/>
<input type="text" name="date2" id="Text2" class="ftxt MyDate three columns" maxlength="10" value="" placeholder="Departure Date" />
<input type="submit" name="bookingformsubmit" class="book-now" value="Book Now">
<input type="hidden" name="arrivalDay" value="" />
<input type="hidden" name="arrivalMonth" value="" />
<input type="hidden" name="arrivalYear" value="" />
<input type="hidden" name="departureDay" value="" />
<input type="hidden" name="departureMonth" value="" />
<input type="hidden" name="departureYear" value="" />
<input type="hidden" name="numAdults" value="1" />
Any help would be greatly appreciated ;)
So they are saying if you can iFrame in their Form on your page and if you add the USERNAME for example to the URL, your USERNAME will appear on the invoice. Like this I believe:
http://www.directinn.com/iframefull.html/BOB
I do not think you can make your own form and POST to their page. I see no indication that that is possible from the link you posted of the example.
The code you have will submit a load of Query String data to the receiving site.
The target site may implement some type of cross-site posting prevention which is causing the blockage - or they may ignore your query string parameters entirely.

Value in the submission form

I've create a RSS submission form and I want to show in the input box something like Enter your email here...., and when they click on it that message should be disappear and they can put their email in the box.
Here is the code I'm using at the moment
<div id="RSS">
<form action="http://feedburner.google.com/fb/a/mailverify" class="RSS" method="post" target="popupwindow" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=RSS', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true">
<input type="hidden" name="uri" value="RSS">
<input type="hidden" name="loc" value="en_US">
<input name="email" id="RSS-text" type="text" maxlength="100" style="width:160px !important" value="Enter your email address..." class=""><button type="submit" id="RSS-button">Subscribe</button>
</form>
</div>
The problem is that it doesn't disappear when someone click on it, and I saw many forms including my search form it can be done that way.
You can use the placeholder attribute, but it doesn't support IE:
<input type="text" placeholder="Enter your text here..." />
Otherwise you can use a bit of javascript:
<input type="text" onfocus="if(this.value=='Enter your text here...') this.value='';" onblur="if(this.value=='') this.value='Enter your text here...';" value="Enter your text here..." />

How does the POST request look with this example data?

<form method="POST" action="http://www.mypage.com/login.php" name="acc">
<input value="mylogin" name="login" size="19" maxlength="30" type="text">
<input maxlength="40" type="password" size="19" name="pass">
</form>
What is the encoded POST request? is it login=mylogin&pass=mypassword or should I use something with acc which is the name of form?
Use $_POST["name"] to receive a variable name from POST form. The name of form isn't necessary to receive arguments from it.

Access a form in asp.NET C#

All the examples I can find are in Visual Basic, but I am using C#.
I want to get the data that is in a textbox in a form.
My code so far:
<form action="login.aspx" method="get">
<p>Username: <input type="text" name="username" /></p>
<p>Password: <input type="text" name="password" /></p>
<input type="submit" value="Submit" />
</form>
So what could I do? Because I keep getting told to do this:
Dim UserName
UserName = Request.Form("UserName")
But it doesn't work in C#.
Don't need to do that on asp.net; simply change your markup like so:
<form action="login.aspx" method="post" runat="server">
<p>Username: <input type="text" name="username" runat="server" id="txtUsername" /></p>
<p>Password: <input type="text" name="password" runat="server" id="txtPassword"/></p>
<input type="submit" value="Submit" />
</form>
And on code behind:
string UserName= txtUsername.Value;
And yes, Shawn also caught a good one, you should use POST.
Your method should be POST.
<form action="login.aspx" method="post">
The sample code you posted is vb.net. C# has it's own syntax and keywords.
to get the value you can use the following (not an optimal solution for webforms)
string userName = Request.Form["UserName"];
I would suggest going through some c# tutorials to get a handle on the language. Here's the first one i found http://www.csharp-station.com/Tutorial.aspx

Resources