how to pass value of text to "a href" - authentication

I need you help me with asp code.
I got a home page that contained User Name and Password for user to log in by using a href attribute and i don't know how to pass the value of text to a href to login.asp file.
Please help me!
Example:
<table>
<tr>
<td>User</td>
<td><input type="text" id="user"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" id="pass"/></td>
</tr>
<tr>
<td>Log in</td>
</tr>
</table>

First of all the username and password text box must be inside a form element
e.g.
<form name="myForm" id="myForm" method="post" action="login.asp">
<input type="text" name="username"/>
<input type="password" name="password"/>
Login
</form>
and in your .asp page you can get the values as
Request.Form("username")
Request.Form("password")

Related

ColdFusion - Using the Query Output to Store Variables For Each Row to Re-Query for Edit

I am definitely a noob at CFML and have been trying to wrap my head around this for some time. I have my query output my data with a Detail button I created that will enter into a new page to edit the information. Each #INV# would have more line items associated to them for review. My goal is to click the button and run a query based off the INV for that given row to return output of all associated line items that need some sort of approval in a new page. Then giving me the ability to edit the data.
I think I need to be able to store the INV column as a variable in my code but am not sure how to accomplish this.
Sorry if it isn't too clear!
<cfquery name="Review" datasource="FINANCE_EQMT_ACCT">
SELECT '1' as ROW, ''ABC CO.' AS OWNER, 'T1234567' AS INV, '50.00' AS TOTAL FROM TBL_TEST
</cfquery>
<div class="container col-xs-12 col-sm-12 col-md-5 col-md-push-1 col-lg-5 col-lg-push-1">
<div class="row">
<table class="table table-striped">
<legend>QUEUE</legend>
<thead>
<tr>
<th class="text-center">#</th>
<th>Owner</th>
<th>Invoice</th>
<th>Amount</th>
<th></th>
</tr>
</thead>
<tbody>
<cfoutput query="Review">
<tr>
<td class="text-center">#ROW#</td>
<td>#OWNER#</td>
<td>#INV#</td>
<td>#TOTAL#</td>
<td class="text-right"><form action="review_action.cfm" method="post"><input class="btn btn-primary" type="submit" value="Detail"></form></td>
</tr>
</cfoutput>
</tbody>
</table>
</div>
</div>
You don't need to save it. You just need to push it over to the next page
...
<td class="text-right">
<form action="review_action.cfm" method="post">
<input type="hidden" name="INV" value="#INV#" />
<input class="btn btn-primary" type="submit" value="Detail">
</form>
</td>
...
review_action.cfm will then process that value as a part of form.inv

I want to extract a text string on the webpage which is written in the form of table, but I am getting null in return

WebElement e5 = d1.findElementByXPath("/html/body/div[1]/div[3]/div/div[1]/form/div/div[1]/div/table/tbody/tr[4]/td[2]");
String a = e5.getText();
System.out.println(a);
_____________________________________________________________________________
I have used getText method. The data is stored in the table, so the strategy which I am making use of is that first of all i want to get to the location of that data using xPath funda and then I need to extract the data corresponding to that location. Can anyone suggest a better way to do so.Thanks in advance.
pls find below the html:
<div class="wrapper">
<form method="post" action="">
<input id="_csrf" type="hidden" value="psJdnI5AnxjGqT2knrZG" name="_csrf">
<div class="innercontainer">
<div class="leftpanel">
<h2>MY ACCOUNT</h2>
<div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<tr>
<td>
<strong>Membership ID:</strong>
</td>
<td>2800000101</td>
</tr>
<tr>
<tr>
<tr> </tr>
<tr>
</tbody>
</table>
</div>
</div>
<div class="rightpanel">
</div>
</form>
</div>
html page added above. Kindly suggest some alternative
You need to clean up your Xpath, however this should help
WebElement tableText = driver.findElement(By.xpath("yourXpath"));
String actualText = tableText.getAttribute("textContent");
System.out.println(actualText)

click on a checkbox selenium java

Hi, I want to b able to click on a check box based on a value. Below is the html of the same:
<tbody>
<tr>
<th>Record Type</th>
<th style="text-align:center">Has Access?</th>
<th style="text-align:center">Can Create?</th>
<th style="text-align:center">Can Read All Records?</th>
</tr>
<tr>
<td>
<input id="ORMW.S2.0.Object Type" class="readOnlyField" type="text" value="Account" maxlength="255" size="25" name="ORMW.S2.0.Object Type" readonly="readonly"/>
</td>
<td align="center">
<input id="ORMW.S2.0.Has Access_VP123456" type="checkbox" onclick="cbValue(this,'ORMW.S2.0.Has\x20Access');" style="margin-left:0px;margin-top:1px;height:10px;width:10px;vertical-align:middle"/>
<input id="ORMW.S2.0.Has Access" type="hidden" value="Y" tabindex="-1" name="ORMW.S2.0.Has Access"/>
</td>
<td align="center">
<td align="center">
I want to click on checkbox based on the value account here.
Next query will search element by #value='Account' then traverse up to the first tr and then search your checkbox:
//input[#type='text' and #value='Account']/ancestor::tr[1]//input[#type='checkbox']
you can also try this:
//input[#type='checkbox' and preceding-sibling::input[#type='text' and #value='Account']]

CFFILE upload - insert file location into SQL db at the same time?

I have a little page that has a form with a few fields in it. Also included is a file upload function. I need to be able to have the filename of the file being uploaded to be inserted into the 'sURL' field, when the form is submitted. (The sURL field can be populated automatically with this filename or can also be manually entered if it is an external URL). I have looked at other people with this issue and there seems to be no straightforward fix? Is anyone able to shed some light?
<html><head>
<title>New Survey Entry</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
function check ( form )
{
if (form.ul_path.value == "") {
alert( "Please select the file to upload." );
form.ul_path.focus();
return false ;
}
return true ;
}
</script>
<CFIF NOT isDefined("dir")>
<CFSET dir = "">
</CFIF>
<CFIF NOT isDefined("clientFile")>
<CFSET clientFile = "">
</CFIF>
<CFQUERY NAME="getpub" DATASOURCE="testpage" DBTYPE="ODBC">
SELECT *
FROM surveypubs
ORDER BY sGroup asc
</CFQUERY>
<h2><center>NEW SURVEY ENTRY</center></h2>
<table cellpadding="3" cellspacing="3" class="font13">
<cfoutput>
<form name="input" enctype="multipart/form-data" action="index.cfml?cat=test&page=insertSurvey" method="post">
<tr>
<td valign="middle" align="left"><b>Year:</b></td>
<td colspan="3"><input name="sYear" type="text" size="8" value="<CFOUTPUT>#year(now())#</CFOUTPUT>"><input name="sYear_required" type="hidden" value="You must enter a Year."></td>
</tr>
</cfoutput>
<tr>
<td valign="middle" align="left"><b>Group:</b></td>
<td colspan="3"> <select name="sGroup">
<option value="">--- Select One ---</option>
<cfoutput query="getpub"><option value="#sGroup#">#sGroup#</option></cfoutput>
</select> <br> Don't see the Survey Group? Click here to add.
</td>
</div><br><br>
</tr>
<tr>
<td valign="middle" align="left"><b>Title:</b></td>
<td colspan="3"><input name="sTitle" type="text" size="85"><input name="sTitle_required" type="hidden" value="You must enter a Title."></td>
</tr>
<tr>
<td valign="middle" align="left"><b>Comment:</b></td>
<td colspan="3"><input name="sComment" type="text" size="85"></td>
</tr>
<tr>
<td valign="middle" align="left"><b>URL:</b></td>
<td colspan="3"><input name="sURL" type="text" size="85"></td>
</tr>
<td valign="bottom" align="left"><b>URL Type:</b></td>
<td colspan="3">
<input type="radio" name="surlType" value="0" checked> Internal <input type="radio" name="surlType" value="1"> External</td>
</tr>
<cfoutput>
<input name="dateAdded" type="hidden" value="#dateformat(now(),"mm-dd-yyyy")#">
</cfoutput>
<tr>
<td></td>
<form action="/index.cfml?cat=test&page=inputSurvey" method="POST" enctype="multipart/form-data" name="upload_form" id="upload_form" onsubmit="return check(this);">
<CFIF structKeyExists(form, "ul_path") and len(form["ul_path"])>
<CFFILE ACTION="UPLOAD" FILEFIELD="ul_path" DESTINATION="D:\testpage\docs\" NAMECONFLICT="OverWrite">
<CFSET ClientFilePath = "#clientDirectory#\#clientFile#">
</CFIF>
<td colspan="3" align="left">Click on the Browse button to select the file to Upload:<br>
<input type="file" name="ul_path" id="ul_path" style="height: 22px;width: 350px;" value=""></td>
</tr>
<tr>
<td></td>
<td colspan="3" align="center"><input type="submit" name="submit" value="Submit"> <input name="clear" value="Clear" type="reset"> <input type="button" name="back" value="Back" class="input" onClick="javascript:history.back();"></td>
</tr>
</table>
</form>
<cfif isDefined("CFFILE.ClientFile")>
<cfset form.sURL = "#CFFILE.ClientFile#">
<cfelse>
<cfset form.sURL = "null">
</cfif>
<cfoutput><input type="hidden" name="sURL" id="sURL" value="http://testpage.com/docs/#ClientFile#"/></cfoutput>
</form>
</body>
</html>
Use the result attribute of cffile, this will then give you a structure of data about your upload, including the directory the file was stored in as well as the file name. Add result='moo' to your cffile call and then do a cfdump of moo to see all the data.
Check out this link for more info on what is returned in result
I sense that what you are trying to do is not being answered here. What you seem to be trying to do is on the client before the file is uploaded. You wish to collect the name of the file the user has chosen from his or her file system and using JS populate some other form field - which may contain the name of the file or possible some URL value or something else provided by the user.
That's different from collecting the name of the form after it is submitted because it runs afoul of browser protections. I really don't think there's an adequate solution in JS to this. You might find a solution that works in some browsers but I doubt it will be consistent.
I could be wrong of course. I'd be glad to have someone show me a solution.

wgetting a forum as a registered user

I want to sample the main page of a forum to do some statistics. The main page is only visible to registered members. How would I download it using wget? I tried logging in via a browser, then passing that browser's cookie file to wget, but it doesn't work.
EDIT: Here's the login form code:
<table border="0" cellpadding="3" cellspacing="1" width="100%">
<tr>
<td colspan="2" align="center"> </td>
</tr>
<tr>
<td width="45%" align="right"><span class="gen">User:</span></td>
<td><input type="text" name="username" size="25" maxlength="40" value="" class="post2" id="focus" onFocus="Active(this)" onBlur="NotActive(this)" /></td>
</tr>
<tr>
<td align="right"><span class="gen">Password:</span></td>
<td><input type="password" name="password" size="25" maxlength="25" class="post2" onFocus="Active(this)" onBlur="NotActive(this)" /></td>
</tr>
<tr align="center">
<td colspan="2"><span class="gen">Remember me: <input type="checkbox" name="autologin" /></span></td>
</tr>
<tr align="center">
<td colspan="2"><input type="hidden" name="redirect" value="" /><input type="submit" name="login" class="mainoption" value="Log in" /></td>
</tr>
<tr align="center">
<td colspan="2"><span class="gensmall">I forgot the password</span></td>
</tr>
</table>
Wget accept some parameters like --http-user=user --http-passwd=password, aside with proxies and certificate methods. Did you try one of these ?
How does the forum authentification works ?
Look at the construction of the login form within that page. If it's a typical POST form, retrieve the names of the elements which make up the form, and construct a wget query which will pass these in to the page that the form is submitted to
In this example, the form fields are called 'username' and 'password':
wget http://www.myforum.com/login.php --post-data="username=jeffrey&password=mypassword"
You will than have downloaded just the login page. With some configuration of other wget options, you should then be able to get it to traverse to the homepage and download this (especially if there is a link to it on the post login page). You may even get lucky and your forum automatically redirects you to the main page after login; in which case, wget will download this for you at that point (depending on the type of redirection issued by the server).