How to pass get parameter via submit button - html

Hello i have a form which i am receiving parameter from previous page, so i want to pass the both value of the form plus parameter which i have received from from previous page.
Here is my code
<?php
$remoteemployeeid = $_GET['RemoteEmployeeID']; // parameter to be pass to next page via submit button
?>
<form action="Remote Employee Transaction History_exe.php" name="TransactionForm" method="post">
<table width="1280px" border="0" cellpadding="3" style="font-family:Verdana; margin-top:30px; margin-left:28px;" align="center">
<tr>
<td height="99" colspan="2" align="left" valign="middle">
<p><font size="+3"> Remote Employee Transaction History Page</font></p>
</td>
</tr>
<tr>
<td width="32%">Remote Employee Earn Amount:</td>
<td width="68%"><input type="number" id="earnamount" name="earnamount" onChange="transaction()" ></td>
</tr>
<tr>
<td>Remote Employee Tax Deduction:</td>
<td><select name="taxdeduction" id="taxdeduction" onChange="transaction()"><br />
<option selected="selected">Tax Deduction</option>
<option value="2">Two Percent</option>
<option value="7">Seven Percent</option>
<option value="10">Ten Percent</option>
</select></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">Remote Employee Amount Payable:</td>
<td bgcolor="#CCCCCC"><input type="number" id="amountpayable" name="amountpayable" readonly></td>
</tr>
<tr>
<td>Remote Employee Amount Paid:</td>
<td><input type="number" id="amountpaid" name="amountpaid" onChange="transaction()" ></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">Remote Employee Amount Remain With Office:</td>
<td bgcolor="#CCCCCC"><input type="number" id="amountremainwithoffice" name="amountremainwithoffice" readonly ></td>
</tr>
<tr>
<td><input type="submit" value="Submit To Database"></td>
</tr>
</table>
</form>

action="Remote Employee Transaction History_exe.php"
change to action="Remote Employee Transaction History_exe.php?RemoteEmployeeID=<?php echo $_GET['RemoteEmployeeID']; ?>"
But beware this is very easy to mess with, as you can change the RemoteEmployeeID by just changing the url in the browser addressfield.
A better approach would be to use php sessions.

Related

Current input value does not get passed to event handler in AngularJS

<tr ng-repeat="item in groups">
<td hidden><input type="hidden" value="{{item.id_group}}" /></td>
<td><input type="text" value="{{item.description}}" class="form-control" /></td>
<td>
Edit |
Delete
</td>
</tr>
So this code was supposed to show values in a table and when the user changes anything in the description and click on Edit, it should POST the new value to the server. Instead it's posting the old value, I need some help please to identify why this is happening.
Try using Ng-model
<tr ng-repeat="item in groups track by $index">
<td hidden><input type="hidden" ng-model="groups[$index].id_group" /></td>
<td><input type="text" ng-model="groups[$index].description" class="form-control" /></td>
<td>
Edit |
Delete
</td>
</tr>

Pre-filling search query's. POST Http

I'm trying to understand how to use query strings in URL's and trying to make some shortcuts to make my job easier. From what I've been reading here and there there are ways to pre-program a website using query parameters. I went to the website I'm interested and pulled the "search form" part that I would like to pre-fill (this is a database search, I would like to have a direct link that just pre-populates and just shows the results of the search instead of me filling it each time I look for new data).
This is from the website's "inspect source". the part of it:
<form id="partInquiry" name="partInquiry" action="PartInquiryForEdit.htm" method="post">
<table style="width: 40%">
<tr>
<td colspan="2" align="left"></td>
</tr>
<tr class="ez1">
<td class="label">Search By:
</td>
<td class="input"><select id="searchby" name="search">
<option value="part_number">Part Number</option><option value="part_description">Part Description</option><option value="rdo_gpl">RDO/GPL</option><option value="rdo_productCd">RDO/Product Code</option>
</select></td>
</tr>
<tr class="ez1">
<td class="label">Match By:
</td>
<td class="input"><select id="matchby" name="match">
<option value="matches">Exactly Matches</option><option value="contains">Contains</option><option value="startsWith">Starts With</option><option value="endsWith">Ends With</option>
</select></td>
</tr>
<tr class="ez1">
<td class="label">Search For:
</td>
<td class="input"><input id="searchfor" name="searchString" type="text" value="" maxlength="750"/> </td>
</tr>
<tr class="ez1">
<td colspan="2"><input type="submit" onclick="clearSession();"
value="Submit"
class="Button" /> <input type="submit"
value="Cancel"
class="Button" /></td>
</tr>
</table>
<BR>
<BR>
<table>
<tr>
<td><label class="errorBox" id="errorBox"></label>
<table>
<tr>
<td></td>
</tr>
</table>
<table>
<tr>
<td></td>
</tr>
</table> <input type="hidden" id="rowsToAdd" name="rowsToAdd" /> <input
type="hidden" id="rowsToRemove" name="rowsToRemove" /> <input
type="hidden" id="rowsToSubmit" name="rowsToSubmit" /> <input
type="hidden" id="isExport" name="isExport" />
<table>
<tr>
<td></td>
</tr>
</table> </td>
<td></td>
</tr>
</table>
<BR>
<BR>
</form>
I tried the following to no avail and I dont know how else to do it:
?search=part_description&searchby=part_description&matchby=contains&match=contains&searchfor=MYSEARCHSTRING&searchString=MYSEARCHSTRING&Submit
?search=part_description&match=matches&searchString=MYSEARCHSTRING&Submit&submit
?searchby=part_description&matchby=matches&searchfor=MYSEARCHSTRING
I'm not sure I'm understanding how to do this or if maybe there's somewhere in the code where It disables this (and how would I find it?). As shown, I tried using the "names" but nothing, I also tried using the "id"s but nothign either. Also I dont know how to actually "submit" the search since the submit button has no id or name. only an "onclick" and a "value".
Pre-populating a form via the query string is something that the website must explicitly support, it's not a general feature. The website must be coded to accept values on the query string and then return the appropriate HTML to pre-select those values.
If the website does not support this, then what you can do as an alternative is create a bookmarklet that populates the fields you want. For example:
javascript:var id=document.getElementById.bind(document);id('searchby').value='part_description';id('matchby').value='matches';id('searchfor')='MYSEARCHSTRING';void 0;
After you've loaded the site, you can click the bookmark to pre-fill the form.

multiple columns in body

Hi I have a form which I want to make 5 forms below in 5 columns in the body. I know that it is possible. Can you please help me ?
----------------------------------------------------
| | | |
| Column 1 | Column 2 | Column 3 |
| | | |
----------------------------------------------------
<table cellspacing="10">
<tr>
<td><font color="black">*</font>Ref. No: </td>
<td><input type="text" onkeypress="return numeric(event); "value="<?PHP if(isset($_POST['code'])) echo htmlspecialchars($_POST['code']);?>" name="code" ></td>
</tr>
<tr>
<td><font color="black">*</font>Serial No: </td>
<td><input type="text" value="<?PHP if(isset($_POST['serialnumber'])) echo htmlspecialchars($_POST['serialnumber']);?>" name="serialnumber"><br></td>
</tr>
<tr>
<td><font color="black">*</font>Item Model: </td>
<td><input type="text" value="<?PHP if(isset($_POST['model'])) echo htmlspecialchars($_POST['model']);?>" name="model"></td>
</tr>
<tr>
<td><font color="black">*</font>Description </td>
<td> <input type="text" value="<?PHP if(isset($_POST['description'])) echo htmlspecialchars($_POST['description']);?>" name="description"><br></td>
</tr>
</table>
A solution to your problem, while using tables, is to put all the labels in the first row, and all the inputs in the second.
http://codepen.io/anon/pen/pyXgyW
<table cellspacing="10">
<tr>
<td><font color="black">*</font>Ref. No: </td>
<td><font color="black">*</font>Serial No: </td>
<td><font color="black">*</font>Item Model: </td>
<td><font color="black">*</font>Description </td>
</tr>
<tr>
<td><input type="text" onkeypress="return numeric(event); "value="<?PHP if(isset($_POST['code'])) echo htmlspecialchars($_POST['code']);?>" name="code" ></td>
<td><input type="text" value="<?PHP if(isset($_POST['serialnumber'])) echo htmlspecialchars($_POST['serialnumber']);?>" name="serialnumber"><br></td>
<td><input type="text" value="<?PHP if(isset($_POST['model'])) echo htmlspecialchars($_POST['model']);?>" name="model"></td>
<td> <input type="text" value="<?PHP if(isset($_POST['description'])) echo htmlspecialchars($_POST['description']);?>" name="description"><br></td>
</tr>
</table>
Expanding on this, you could nest your form table inside another four or five column table, like this: http://codepen.io/anon/pen/pyXgyW
Regarding the table:
Each row in a table is tagged by <tr>.
In this (row) you may insert any data as <td> (table data)
Column headers are tagged by <th> (table head(er))
Regarding the form:
To reach your goal you have to choose from 2 ways:
You use javascript to create a formData element and just add the data of the inputs. See: https://developer.mozilla.org/en-US/docs/Web/API/FormData/append
You create the form and add a table into it holding different inputs in the cells. Don't forget to name them so you can reach the data to serverside.
I would choose the first way.

How to read multiple textboxes and insert into database?

How can I update multiple textbox in database using ASP.NET Web Pages(razor syntax). I want to edit emails of students. And the number of rows containing textbox varies or dynamic. Somebody help.
<tr>
<th>Name</th>
<th>Email</th>
</tr>
<tr>
<td>Jason</td>
<td><input type="text" name="txtbox1"></td>
</tr>
<tr>
<td>Kripkee</td>
<td><input type="text" name="txtbox2"></td>
</tr>
<tr>
<td>Kane</td>
<td><input type="text" name="txtbox3"></td>
</tr>
<tr>
<td>Michael</td>
<td><input type="text" name="txtbox4"></td>
</tr>
<tr>
<td><input type="submit" value="Update"></td>
</tr>
</table>
</form>
You can try this:
Assuming you have a view model providing a list of students.
View -
#foreach (var student in Model.Students)
{
<tr>
<td>#student.Name</td>
<td><input name="studentEmails[#student.Id]"/></td>
</tr>
}
Controller -
public ActionResult UpdateEmails(IDictionary<int, string> studentEmails)

Geting the first line in the textarea from database

I am trying to retrieve the value of an HTML textarea in jsp page from mysql database.The problem I am having is that I only can get he first line in the textarea(When I'm saving address in databse, It's retrieving first line only). This is happening for text box also, where data has space in the database, it's only getting first line of the data.
Thanks in advance.
HTML Code:
<div class="container2">
<table>
<tr>
<td align="right">TPO Name</td>
<td><input type="text" readonly name="tponame" value=<%=rs.getString("tponame")%>></td>
</tr>
<tr>
<td align="right">Name of College</td>
<td><input type="text" readonly name="college_name" value=<%=rs.getString("college_name")%>></td>
</tr>
<tr>
<td align="right">Contact Number</td>
<td><input type="text" name="contactno" value=<%=rs.getString("contactno")%>></td>
</tr>
<tr>
<td align="right">Contact Email</td>
<td><input type="text" name="contactemail" value=<%=rs.getString("contactemail")%>></td>
</tr>
<tr>
<td align="right">Address</td>
<td><input type="text" name="address" value=<%=rs.getString("address")%>></td>
</tr>
<tr>
<td colspan="2"><input type="submit" class="button" value="Update" style="float:right;"></input></td>
</tr>
JSP code:
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/FMS","root","root");
Statement st=con.createStatement();
String tponame= request.getParameter("tponame");
String college_name=request.getParameter("college_name");
String contactno=request.getParameter("contactno");
String contactemail=request.getParameter("contactemail");
String address=request.getParameter("address");
String sql = ("update tpo_details set contactno='"+contactno+"',contactemail='"+contactemail+"',address='"+address+"' where tponame='"+tponame+"'");
st.executeUpdate(sql);
response.sendRedirect("update_tpo_network_data.jsp");
%>