So I'm trying to update a record within a table I created. The form processes but for some reason I don't see the table columns updated. The HTML form is
<form action="divProgramProcess.asp?div=<% =divrec %>" id="countInput" class="contact_form">
<input type="text" name="Shipment_Current" id="Shipment_Current" value="<% =Shipment_Current %>" />
<input type="text" name="Couch_Current" id="Couch_Current" value="<%= Couch_Current %>" />
<input type="text" name="Person_Available_Current" id="Person_Available_Current" value="<%= Person_Available_Current %>" />
</form>
The code within divProgramProcess.asp is
<%
divrec = request.QueryString("div")
Set rstest = Server.CreateObject("ADODB.Recordset")
rstest.locktype = adLockOptimistic
sql = "SELECT top 1 * FROM CensusFacility_Records_Last WHERE Count = '1239' "
rstest.Open sql, db
%>
<body>
<%
Shipment_Current = request.form("Shipment")
Couch_Current = request.form("Couch")
Person_Available_Current = request.form("Person_Available")
rstest("Shipment") = Shipment_Current
rstest("Couch") = Couch_Current
rstest("Person_Available") = Person_Available_Current
rstest.update
Response.Redirect("chooseScreen.asp")
%>
If you have some information you know you're going to pass, you may find it easier to just set it as a hidden input.
For example, instead of what you're doing above, do this with your form:
<form action="divProgramProcess.asp" id="countInput" class="contact_form">
<input type="text" name="Shipment_Current" id="Shipment_Current" value="<% =Shipment_Current %>" />
<input type="text" name="Couch_Current" id="Couch_Current" value="<%= Couch_Current %>" />
<input type="text" name="Person_Available_Current" id="Person_Available_Current" value="<%= Person_Available_Current %>" />
<input type="hidden" name="div" value="<% =divrec %>" />
</form>
And pull the value of div from the Request.Form collection.
Related
I'm trying to set the storage class of an uploaded image to an AWS S3 bucket. I have it working except for adding the storage class to the request. The S3 Post Object Documentation states there can be a form input field named "x-amz-storage-class" but adding it, or any other field, throws an AWS error indicating that there are too many input fields for the post. I tried adding it to the object policy but that causes an Policy error: "Policy Condition failed: [“eq”, “$x-amz-storage-class”, “ONEZONE_IA”]". I'm using JSP and the form's input fields are shown below. Any help would be appreciated.
<input type="hidden" name="key" value="<%= imageFileName %>">
<input type="hidden" name="AWSAccessKeyId" value="<%= S3AccessKeyId %>">
<input type="hidden" name="acl" value="private">
<input type="hidden" name="success_action_redirect" value="<%= s3SuccessAction %>">
<input type="hidden" name="policy" value="<%= encPolicy %>" >
<input type="hidden" name="signature" value="<%= signature %>" >
<input type="hidden" name="Content-Type" value="image/jpeg">
<input type="hidden" name="x-amz-storage-class" value="ONEZONE_IA"> ***** CAUSES ERROR ****
Errors:
Invalid according to Policy: Policy Condition failed: [“eq”, “$x-amz-storage-class”, “STANDARD_IA”]
<Error>
<Code>AccessDenied</Code>
<Message>
Invalid according to Policy: Extra input fields: x-amz-storage-class
</Message>
<RequestId>1104FC046523752C</RequestId>
<HostId>
m0xPpMKJqBG6kZsdQfl/RY92dHprnvtGtrijHLqVtieM51ew+Mkp0mXGbTwKM7OsoUq6ZZUVIc0=
</HostId>
</Error>
I have this working now. The policy has fields that must match the fields on the form. "x-amz-storage-class" has to be added to both the form fields and policy. My guess is the encoded policy is signed for security reasons which makes it secure and the form fields must match the policy fields to ensure they weren't changed. Why both are needed is beyond me. Corrected code is below:
<fieldset>
<input type="hidden" name="key" value="<%= imageFileName %>">
<input type="hidden" name="AWSAccessKeyId" value="<%= S3AccessKeyId %>">
<input type="hidden" name="acl" value="private">
<input type="hidden" name="success_action_redirect" value="<%= s3SuccessAction %>">
<input type="hidden" name="policy" value="<%= encPolicy %>" >
<input type="hidden" name="signature" value="<%= signature %>" >
<input type="hidden" name="Content-Type" value="image/jpeg">
<input type="hidden" name="x-amz-storage-class" value="ONEZONE_IA">
public static String encodeS3Policy(String s3SuccessAction, String bucket) throws Exception
{
String policy =
"{\"expiration\": \"2040-01-01T00:00:00Z\"," +
"\"conditions\": [" +
"{\"bucket\": \"" + bucket + "\"}," +
"[\"starts-with\", \"$key\", \"\"]," +
"{\"acl\": \"private\"}," +
"{\"success_action_redirect\": \"" + s3SuccessAction + "\"}," +
"[\"starts-with\", \"$Content-Type\", \"\"]," +
"{\"x-amz-storage-class\": \"ONEZONE_IA\"}," +
"[\"content-length-range\", 0, 10485760]" + // 10 MB max file up load
"]" +
"}";
policy.replaceAll("\n","").replaceAll("\r","");
// Encode the policy
String encPolicy = Base64.getEncoder().encodeToString(policy.getBytes("UTF-8"));
return encPolicy;
}
For completeness and because its not obvious, the storage class values are:
Default: STANDARD
STANDARD | REDUCED_REDUNDANCY | GLACIER | STANDARD_IA | ONEZONE_IA | INTELLIGENT_TIERING | DEEP_ARCHIVE
Here is the AWS S3 Post Object documentation
<% if (p.type === "boolean") { %>
<label class="form-label"><%= p.name%></label>
<input type="radio" class="radio-inline" name="<%= p.name%>[value]=" true " [(ngModel)]="model.<%=p .name%>"> True
<input type="radio" class="radio-inline" name="<%= p.name%>" [value]="false" [(ngModel)]="model.<%= p.name%>"> False
<% } else if (p.type === "date"){ %>
<label class="form-label"><%= p.name%></label>
<input type="date" class="text-input" name="<%= p.name%>" [ngModel]="model.<%= p.name%> | date:'yyyy-MM-dd hh:ii'" (ngModelChange)="model.<%= p.name%> = $event">
<% } else { %>
<label class="form-label"><%= p.name%></label>
<input type="date" class="text-input" name="<%= p.name%>" [ngModel]="model.<%= p.name%> | date:'yyyy-MM-dd hh:ii'" (ngModelChange)="model.<%= p.name%> = $event">
<% } %>
Can anyone help me out here with this code here returning me an error
Unexpected token else while compiling ejs
I need to set the value 12, which is defined as Public PageSize As Integer = 12 in aspx page, to the hidden field in vb.net.I defined hidden field as :
<asp:HiddenField id="ivar" runat="server" Value="<%= PageSize %>"/>.
After running the code and took view source it is just <input type="hidden" name="ivar" id="ivar" value="<%= PageSize %>" />.Not got as <input type="hidden" name="ivar" id="ivar" value="12" />
Use single quotes instead of double:
value='<%= PageSize %>"/>'
<asp:HiddenField id="ivar" runat="server" Value="<%#Eval("PageSize")%>"/>
plz try this
<form action="uploads.php" method="post" enctype="multipart/form-data" id="upload" class="upload">
<fieldset>
<legend>Upload</legend><br/>
Title: <input type="text" name="name" id="name" class="name" required> <br/><br/>
<textarea name="description" rows="6" cols="35" maxlength="120"></textarea><br/>
<input type="file" id="file" name="file[]" required multiple> <br/>
<input type="submit" id="submit" name="submit" value="Upload">
</fieldset>
<div class="bar">
<span class="bar-fill" id="pb"><span class="bar-fill-text" id="pt"></span></span>
</div>
<div id="uploads" class="uploads">
Uploaded file links will appear here.
</div>
<?php
// configuration
$dbhost = "localhost";
$dbname = "blog";
$dbuser = "root";
$dbpass = "pass";
// database connection
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
// new data
$name = 'name';
$mime = 'mime';
$data = 'data';
$size = 'size';
$description = 'description';
$created = 'created';
$url = 'url';
// query
$sql = "INSERT INTO videos (name,mime,data,size,description,created,url) VALUES (:name,:mime,:data,:size,:description,:created,:url)";
$q = $conn->prepare($sql);
$q->execute(array(':name'=>$name,
':mime'=>$mime,
':data'=>$data,
':size'=>$size,
':description'=>$description,
':created'=>$created,
':url'=>$url));
?>
I'm not so good with PDO, I can get videos to upload to my db, but I can't take in a name or anything. It just shows: name, description, size is 0 and etc. I've watched a few tutorials, but none of them show how to add it by what the user names it or describes it as, only what they put into the values goes to the database. I've also searched around on here and many other websites, but no luck.
I am having some difficulty with one of our service providers login forms. The other sites are working fine but for some reason I can't get past their login form.
The website login for is like this:
<form accept-charset="UTF-8" action="/sessions" class="new_user_session" id="new_user_session" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="kaLEkPesQfeheronzGTdfnVAzpuUiC+VmjVXBu540n8=" /></div>
<fieldset class="big">
<div class="form-row">
<div class="form-label">
<label for="user_session_email">Email</label>
</div>
<div class="form-field">
<input id="user_session_email" name="user_session[email]" size="30" type="text" />
</div>
</div>
<div class="form-row">
<div class="form-label">
<label for="user_session_password">Password</label>
</div>
<div class="form-field">
<input id="user_session_password" name="user_session[password]" size="30" type="password" />
</div>
<div class="form-comment"><p>Forgot your password?</p></div>
</div>
<div class="form-row optional">
<div class="form-field">
<label for="user_session_remember_me"><input name="user_session[remember_me]" type="hidden" value="0" /><input id="user_session_remember_me" name="user_session[remember_me]" type="checkbox" value="1" /> Remember me for 2 weeks</label>
</div>
</div>
</fieldset>
I have tried to login using the same code as other the other sites but it doesn't work.
# Create a new mechanize object
agent = Mechanize.new
# Load the dial9 website
page = agent.get("http://webapplication.co.uk")
# Select the first form
form = agent.page.forms.first
form.username = 'username
form.password = 'password'
# Submit the form
page = form.submit form.buttons.first
I have also tried a different way of logging in as suggested in other SO questions/answers:
email = 'user#domain.com'
password = 'password
# Create a new mechanize object
agent = Mechanize.new
# Load the postmarkapp website
page = agent.get("https://domain.com")
# Select the first form
form = agent.page.forms.first
form.field_with(:email => "user_session_email").value = email
form.field_with(:password => "user_session_password").value = password
# Submit the form
page = form.submit form.buttons.first
Using this method of authentication I get the following output when running the rake task:
undefined method `email' for [hidden:0x3fef2ab2b994 type: hidden name: utf8 value: ✓]:Mechanize::Form::Hidden
Upon closer inspection the above error seems to be due to the fact that there is a field immediately after the form is started:
<form accept-charset="UTF-8" action="/sessions" class="new_user_session" id="new_user_session" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="kaLEkPesQfeheronzGTdfnVAzpuUiC+VmjVXBu540n8=" /></div>
Am I missing something? If so, what? Any pointers are appreciated!
Try changing
form.field_with(:email => "user_session_email").value = email
form.field_with(:password => "user_session_password").value = password
to
form.field_with(:name => "user_session[email]").value = email
form.field_with(:name => "user_session[password]").value = password