I've almost got the CAPTCHA system working on this particular website. I've used the captcha form from http://www.tipstricks.org. Everything seems to be working except that when I fill out the contact form the values don't get submitted through e-mail. I just get the contact from with all the values missing. I'm not sure how to pass in the values from the form so that it is included in the e-mail. Here is the code on this particular asp page:
<form name="form1" id="form1" method="post" action="send_email.asp" value="<%
If Session("form1") <> "" Then Response.Write(Session("form1"))%>" />
<table border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td>Contact Name</td>
<td width="20" align="center">:</td>
<td><input name="name" type="text" id="name" size="30"></td>
</tr>
<tr>
<td>E-mail Address</td>
<td align="center">:</td>
<td><input name="email" type="text" id="email" size="30"></td>
</tr>
<tr>
<td>Comments</td>
<td align="center">:</td>
<td><input name="comments" type="text" id="comments" size="30"></td>
</tr>
<tr>
<td> </td>
<td align="center"> </td>
</tr>
</table>
<div style="text-align: center; margin-top: 20px;">
<%
if Request.ServerVariables("REQUEST_METHOD") = "POST" and IsEmpty(Request.Form("btnRetry")) then
Dim lblResult, lblColor
if IsEmpty(Session("ASPCAPTCHA")) or Trim(Session("ASPCAPTCHA")) = "" then
lblResult = "This test has expired."
lblColor = "red"
else
Dim TestValue : TestValue = Trim(Request.Form("txtCaptcha"))
'//Uppercase fix for turkish charset//
TestValue = Replace(TestValue, "i", "I", 1, -1, 1)
TestValue = Replace(TestValue, "İ", "I", 1, -1, 1)
TestValue = Replace(TestValue, "ı", "I", 1, -1, 1)
'////////////////////
TestValue = UCase(TestValue)
if StrComp(TestValue, Trim(Session("ASPCAPTCHA")), 1) = 0 then
lblResult = "CAPTCHA PASSED"
lblColor = "green"
Session("form1") = Request.Form("form1")
response.redirect "send_email.asp"
else
lblResult = "CAPTCHA FAILED"
lblColor = "red"
end if
'//IMPORTANT: You must remove session value for security after the CAPTCHA test//
Session("ASPCAPTCHA") = vbNullString
Session.Contents.Remove("ASPCAPTCHA")
'////////////////////
end if
%>
<p><span style="color: <%=lblColor%>; font-weight: bold;"><%=lblResult%></span></p>
<input type="submit" name="btnRetry" id="btnRetry" value="Take another test" />
<%else%>
<img src="captcha.asp" id="imgCaptcha" /> Get a new challenge<br />
Write the characters in the image above<br />
<input type="text" name="txtCaptcha" id="txtCaptcha" value="" /><br />
<input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
<%end if%>
</form>
Any help would be greatly appreciated.
Related
<form data-request="onSend" data-request-update="'{{ __SELF__}}::attbanco': '#banco' "
data-request-flash >
<table>
<tr>
<td>Nome: </td> <td ><input type="text" id="nome" name="nome"></td>
</tr>
<tr>
<td>Idade: </td> <td ><input type="number" id="idade" name="idade" value="{{usuario.idade}}"></td>
</tr>
<tr>
<td>Telefone: </td> <td ><input type="text" id="telefone" name="telefone" value="{{usuario.telefone}}"></td>
</tr>
</table>
<button type="submit" >Enviar</button>
<input type="hidden" value="{{usuario.id}}" name="id">
this code work, saves the values on database, but i need manually refresh page to see the result on my
screen, someone know how refresh after submit?
Please, explain most simple possible, i am newbie
The best way to do what you want is to put the form in a partial and update it when the form is submitted.
Replace your form with this:
<div id="specialForm">
{% partial __SELF__~"::specialForm" %}
</div>
Create a partial to describe the form; I used specialForm. It should reload the form and clear the content.
<form data-request="onSend" data-request-update="'{{ __SELF__}}::attbanco': '#banco', '{{ __SELF__ }}::specialForm': '#specialForm' "
data-request-flash >
<table>
<tr>
<td>Nome: </td> <td ><input type="text" id="nome" name="nome"></td>
</tr>
<tr>
<td>Idade: </td> <td ><input type="number" id="idade" name="idade" value="{{usuario.idade}}"></td>
</tr>
<tr>
<td>Telefone: </td> <td ><input type="text" id="telefone" name="telefone" value="{{usuario.telefone}}"></td>
</tr>
</table>
<button type="submit" >Enviar</button>
<input type="hidden" value="{{usuario.id}}" name="id">
</form>
I have a table like this:
<table>
<tbody>
...
<tr>
<td>
<div class="radio-inline">
<input name="sms_provider" type="radio" value="2" id="2">
<label class="text-gray-dark" for="2"> </label>
</div>
</td>
<td data-label="Server name">ServerA3</td>
<td data-label="Description"></td>
<td data-label="Status">
<label class="text-success">
<clr-icon shape="check"></clr-icon>
Default
</label>
</td>
<td data-label="Actions">
<a href="http://example.com/public/smsconfigurations/2/edit" data-tooltip="Edit Server">
<clr-icon shape="pencil" size="22" style="width: 22px; height: 22px;"></clr-icon>
</a>
</td>
</tr>
...
</tbody>
</table>
Now I wanna to check ServerA3 has Default status or no. As matter of fact I expect ServerA3 has Default text as siblings. What should I do?
I try with this code, but it doesn't work:
expect(element(by.xpath('//td[contains(text(), "ServerA3")]')).getWebElement().getDriver().findElement(by.css('*[data-label="status"]')).getText()).toContain('Default');
var status = element(by.xpath('//tr[td[.="ServerA3"]]/td[#data-label="Status"]'))
.getAttribute('innerText');
expect(status).toEqual('Default')
Let's say I have rendered the output rom the get request on an html template, now I need to use this same data to pass to a post request via a button on a same page. How do I do that?
I'm trying to do something like this:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Customer Home</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div th:replace="fragments/header :: header">
</div>
<div class="container">
<p> Thanks for booking with Gamma Airlines, here are your booking summary: </p>
<table th:object="${booking} class="table table-bordered table-striped">
<tbody>
<tr>
<td>Source</td>
<td th:text="${routeStart}"></td>
</tr>
<tr>
<td>Destination</td>
<td th:text="${routeDestination}"></td>
</tr>
<tr>
<td>Booking Charges</td>
<td th:text="${bookingCharges}"></td>
</tr>
<tr>
<td>Booking Charges Currency</td>
<td th:text="${chargesCurrency}"></td>
</tr>
<tr>
<td>Booking Date</td>
<td th:text="${#calendars.format(bookingDate)}">July 11, 2012 2:17:16 PM CDT</td>
<tr>
<td>
<div class="col-sm-9">
<form action="#" th:action="#{/email}"
th:object="${booking}" method="post"
role="form">
<button type="submit" class="btn btn-primary btn-block">Email</button>
</form>
</div>
</td>
<td>
<div class="col-sm-9">
<form action="#" th:action="#{/genpdf}"
th:object="${booking}" method="post"
role="form">
<button type="submit" class="btn btn-primary btn-block">Generate PDF</button>
</form>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Edit: Somebody please help tell me a simple method to pass the object since I have to use it at many places and object contains many child object as well in some cases. eg. the following case:
<div style = "margin-top: 2cm" class="container">
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>Source</td>
<td>Destination</td>
<td>Amount</td>
<td>Currency</td>
<td>Action</td>
</tr>
</thead>
<tbody>
<tr th:if="${offers.empty}">
<td colspan="5">No Offers</td>
</tr>
<tr th:each="offer : ${offers}">
<td th:text="${offer.route.from}"></td>
<td th:text="${offer.route.to}"></td>
<td th:text="${offer.price.amount}"></td>
<td th:text="${offer.price.currency}"></td>
<td>
<form action="#" th:action="#{/user/booking}"
th:object="${offer}" method="post"
role="form">
<button type="submit" class="btn btn-primary btn-block">Book</button>
</form>
</td>
</tr>
</tbody>
</table>
</div>
UPDATE 2:
I even changed the template by sending a new object in the get request and try to assign values one by one but I still get it as null in a controller.
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>Source</td>
<td>Destination</td>
<td>Amount</td>
<td>Currency</td>
<td>Action</td>
</tr>
</thead>
<tbody>
<tr th:if="${offers.empty}">
<td colspan="5">No Offers</td>
</tr>
<tr th:each="offer : ${offers}">
<td th:text="${offer.route.from}"></td>
<td th:text="${offer.route.to}"></td>
<td th:text="${offer.price.amount}"></td>
<td th:text="${offer.price.currency}"></td>
<td>
<form action="#" th:action="#{/user/booking}"
th:object="${booking}" method="post"
role="form">
<input type="hidden" th:attr="value = ${offer.route.from}" th:field="*{routeStart}" />
<input type="hidden" th:attr="value = ${offer.route.to}" th:field="*{routeDestination}" />
<input type="hidden" th:attr="value = ${offer.price.amount}" th:field="*{bookingCharges}" />
<input type="hidden" th:attr="value = ${offer.price.currency}" th:field="*{chargesCurrency}" />
<button type="submit" class="btn btn-primary btn-block">Book</button>
</form>
</td>
</tr>
</tbody>
</table>
These are my get and post methods:
#RequestMapping(value="/user/booking", method = RequestMethod.GET)
public ModelAndView getOffers()
{
ModelAndView modelAndView = new ModelAndView();
AirlineOffer[] offersArray= airlineClient.getOffers();
List<AirlineOffer> offers = Arrays.asList(offersArray);
modelAndView.addObject("offers", offers);
Booking booking = new Booking();
modelAndView.addObject("booking", booking);
modelAndView.setViewName("user/booking");
return modelAndView;
}
/** POST method for submitting deposit request */
#RequestMapping(value = "/user/booking", method = RequestMethod.POST)
public ModelAndView book(#Valid Booking booking,
BindingResult bindingResult, HttpServletRequest request)
{
ModelAndView modelAndView = new ModelAndView();
......
}
Alright, I finally resolved it using the following in my form:
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>Source</td>
<td>Destination</td>
<td>Amount</td>
<td>Currency</td>
<td>Action</td>
</tr>
</thead>
<tbody>
<tr th:if="${offers.empty}">
<td colspan="5">No Offers</td>
</tr>
<tr th:each="offer, stat : ${offers}">
<td th:text="${offer.route.from}"></td>
<td th:text="${offer.route.to}"></td>
<td th:text="${offer.price.amount}"></td>
<td th:text="${offer.price.currency}"></td>
<td>
<form action="#" th:action="#{/user/booking}"
th:object="${booking}" method="post"
role="form">
<input type="hidden" th:value="${offer.route.from}" name="routeStart" />
<input type="hidden" th:value = "${offer.route.to}" name="routeDestination" />
<input type="hidden" th:value = "${offer.price.amount}" name="bookingCharges" />
<input type="hidden" th:value = "${offer.price.currency}" name="chargesCurrency" />
<button type="submit" class="btn btn-primary btn-block">Book</button>
</form>
</td>
</tr>
</tbody>
All it took was to remove th:field and add the name attribute.
I am trying to add a new row of fields after the first row when you click the "Add New Participant" button. I've looked at a few sources and followed suggestions but first of all with this ng-repeat in the code, my fields do not show up. And when I click the "Add New Participant" nothing happens. Not sure what I've got wrong here.
HTML:
<table class="col-md-12" id="client-table">
<tr>
<td></td>
<td>Given Name*</td>
<td>Middle Name</td>
<td>Last Name*</td>
<td>Date of Birth*</td>
<td>Nationality</td>
<td>Gender</td>
<td>Adult or Student</td>
</tr>
<tr data-ng-repeat="travelers in traveler">
<td>1.</td>
<td>
<input type="text" placeholder="Given Name" ng-model="travelersForm.givenName"/>
</td>
<td>
<input type="text" placeholder="Middle Name" ng-model="travelersForm.middleName"/>
</td>
<td>
<input type="text" placeholder="Last Name" ng-model="travelersForm.lastName"/>
</td>
<td>
<input type="date" class="date-picker"/>
</td>
<td>
<input type="text" placeholder="Nationality" ng-model="travelersForm.nationality"/>
</td>
<td>
<select name="gender" id="gender" ng-model="travelersForm.gender">
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</td>
<td>
<select name="student" id="student" ng-model="travelersForm.types">
<option value="student">Student</option>
<option value="adult">Adult</option>
</select>
</td>
</tr>
<tr>
<td>
<button ng-show="showAddTraveler(traveler)" ng-click="addNewTraveler()">Add New Participant</button>
</td>
</tr>
</table>
ANGULARJS
angular.module("travelers", [])
.controller("travelersController", function($scope) {
$scope.travelersForm = {};
$scope.travelersForm.givenName = "Test";
$scope.travelersForm.middleName = "T";
$scope.travelersForm.lastName = "Tester";
$scope.travelersForm.nationality = "White";
$scope.travelersForm.gender = "male";
$scope.travelersForm.types = "adult";
$scope.travelers = [];
$scope.addNewTraveler = function() {
var newItemNo = $scope.travelers.length+1;
$scope.travelers.push({'id':'travelers'+newItemNo});
};
$scope.showAddTraveler = function(choice) {
return travelers.id === $scope.travelers[$scope.travelers.length-1].id;
};
} );
Because your ng-repeat syntax is flipped:
Change:
data-ng-repeat="travelers in traveler">
To:
data-ng-repeat="traveler in travelers">
I have the following html:
<table>
<tr>
<td>
<input type="button" id="btnAdd" value="Add" />
<input type="hidden" id="hdnID" value='209' class="hdn" />
</td>
</tr>
<tr>
<td>
<input type="button" id="btnAdd" value="Add" />
<input type="hidden" id="hdnID" value='210' class="hdn" />
</td>
</tr>
<tr>
<td>
<input type="button" id="btnAdd" value="Add" />
<input type="hidden" id="hdnID" value='211' class="hdn" />
</td>
</tr>
</table>
I have a jQuery click event for the add buttons.
$("#btnAdd").click(function ($e) {
// Need selector here that can find the hidden field (see above) that is found
// in the same td as the button that was clicked. For example, if the Add button
// in the 2nd row was clicked then I need to find the hidden input that has
// the value of '210'.
// Doesn't work... not sure why
var hdn = $(this).siblings().next();
});
Thanks in advance for helping me through a thick moment...
Maybe something like this would work?
("#btnAdd").click(function ($e) {
var hdn = $(this).parent().next().children('td input');
});