Change input values of boxes using Javascript - javascript

I have a form that is being used to generate an email template. At the bottom of the page I have a table that displays the email name, and which departments have access to use it. Ultimately what I want to happen is make the name of the email at the bottom of the page to act like a button. When the user clicks on the email name, it will grab those values from the DB and pass them into the appropriate input field. Below is a sample of my current PHP code. If someone could provide a suggestion or even an example I would be grateful.
This is the form for the email template setup:
<form id="Email" name="Email" method='post' action="<?php echo htmlspecialchars($_SERVER['PHP']);?>">
<fieldset style="width: auto; height: auto;">
<legend class="legend1"><h2> Manage E-Mails </h2></legend>
<table width="100%" style="text-align:center">
<tr>
<td width="60%" style="text-align: left;">
<input type="text" id="name" name="name" placeholder="Email Template Name" value="" maxlength="100" style="width: 250px; height: 20px;"/>
<input type="radio" name="from" id="from" value="user" />Send From User
</td>
</tr>
<tr>
<td style="text-align: left;">
<input type="text" style="width:250px; height: 20px; visibility: hidden;" />
<input type="radio" name="from" id="from" value="department" />Send From Department
</td>
</tr>
<tr>
<td style="text-align: left;">
<input type="text" id="To" name="To" placeholder="To: " value="" maxlength="250" style="width: 250px; height: 20px;"/>
<input type="checkbox" name="user" id="user" value="YES" />Autocopy User
<?php echo "         ";?><input type = "checkbox" name="escalate" id="escalate" value="YES" />Make Escalated Email Only
</td>
</tr>
<tr>
<td style="text-align: left;">
<input type="text" id="CC" name="CC" placeholder="CC: " value="" maxlength="100" style="width: 250px; height: 20px;"/>
<input type="checkbox" name="customer" id="customer" value="YES" />Autocopy Customer
</td>
</tr>
<tr>
<td style="text-align: left;">
<input type="text" id="BCC" name="BCC" placeholder="BCC: " value="" maxlength="100" style="width: 250px; height: 20px;"/>
<input type="checkbox" name="additional" id="additional" value="YES" />Allow Additional Email Address(es)
</td>
</tr>
<tr>
<td colspan=2 style="text-align: left;">
<input type="text" id="subject" name="subject" placeholder="Subject " value="" maxlength="100" style="width: 400px; height: 20px;"/>
Keywords
</td>
</tr>
<tr>
<td style="text-align: left;">
<textarea name="content" maxlength="3000" cols="100" rows="12"></textarea>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Submit" style="float: left;">
</fieldset>
</form>
This is the form that allows users to update what department the email will belong to. This where it will display the email name. I want the email name to be clickable and to generate the info back into the table above.
<form id = "Display_Email" name="Display_Email" method="post" action="<?php echo htmlspecialchars($_SERVER['PHP']);?>">
<?php
$get_business = mysql_query("SELECT bus_name, bus_id FROM business where bus_id = '{$_SESSION['bus_id']}'");
while(($business = mysql_fetch_assoc($get_business)))
{
echo '
<h3>'.$business['bus_name'].'</h3>
<table class="departments">
<tr>
<th scope="col" style="width: 175px;">Email Name</th>
';
$get_depts = mysql_query("SELECT dept_name FROM depts where bus_id = '{$_SESSION['bus_id']}'");
while(($department = mysql_fetch_assoc($get_depts)))
{
echo '
<th scope="col" style="width: 175px;">'.$department['dept_name'].'</th>
';
}
echo '
</tr>
';
$get_emails = mysql_query("SELECT id, email_name from emails where bus_id = '{$_SESSION['bus_id']}' ORDER BY email_name ASC");
while(($email = mysql_fetch_assoc($get_emails)))
{
echo '
<tr>
<td>'.$email['email_name'].'</td>
';
$get_depts = mysql_query("SELECT dept_name, dept_id FROM depts where bus_id = '{$_SESSION['bus_id']}'");
while(($department = mysql_fetch_assoc($get_depts)))
{
$get_email_dept = mysql_query("SELECT dept_id from emails where id = '{$email['id']}'");
while(($email_dept = mysql_fetch_assoc($get_email_dept)))
{
$departments = explode(",", $email_dept['dept_id']);
if(in_array($department['dept_id'], $departments, TRUE))
{
echo '<input type="hidden" name="Email_Box[]" value="0">';
echo '<td><input type="checkbox" name="Email_Box[]" value="'.$department['dept_id'].'" checked="checked""></td>';
}
else
{
echo '<input type="hidden" name="Email_Box[]" value="0">';
echo '<td><input type="checkbox" name="Email_Box[]" value="'.$department['dept_id'].'"></td>';
}
}
}
echo '
</tr>
';
}
echo '
</table>
';
}
?>
<input type="submit" name="Email_Submit" value="Submit" style="float: left;"/>
</form>

Related

Total sum of columns of one row

I want to add the column values in text box field of each single row during insertion of value to that field and display that value in a read only field.
HTML CODE:
<form action="" method="post">
<table class="table-responsive">
<thead>
<tr>
<th style="width: 10%;">Task Name</th>
<th style="width: 10%;">Task Code</th>
<th style="width: 10%;">LDR</th>
<th style="width: 10%;">SDR</th>
<th style="width: 30%;">Total</th>
</tr>
</thead>
<?php
while($m_row = $m_result->fetch_assoc()) {
?>
<tbody>
<tr>
<?php
$sqltask="SELECT * FROM tasks WHERE tasks_code='".$m_row['tcode']."'";
$resulttask=$conn->query($sqltask);
$rowtask=$resulttask->fetch_assoc();
?>
<td><?php echo $rowtask['tasks_name'] ?></td>
<td><?php echo $m_row['tcode'] ?></td>
<td>
<input type="text" class="form-control master" name="ldr[]" id="ldr" value="<?php echo $m_row['ldr'];?>" placeholder="" autocomplete="off">
</td>
<td>
<input type="text" class="form-control master" name="sdr[]" id="sdr" value="<?php echo $m_row['sdr'];?>" placeholder="" autocomplete="off">
</td>
<td>
<input type="number" class="form-control master" id="master_diff" name="master_diff[]" readonly />
</td>
<td> <input type="hidden" name="master[]" id="master" value="<?php echo $master_row['id'];?>" /></td></tr>
</tbody>
<?php
}
?>
</table>
<div class="pull-right">
<input type="submit" class="btn btn-primary" name="mastertask" placeholder="Assign"/>
</div>
</div>
</div>
</div>
</form>
The above code is the html code for the textbox fields where the fields ldr,sdr should be sumup for getting the total sum in master_diff field. It should be using onchange event since each entry to the textbox fields should be get added to display the final sum.
You should to remove all ids from the cycle!
Try this:
var inputs = document.getElementsByClassName("inputs");
var summDiff = function() {
var tr = this.closest("tr");
var ldr = tr.getElementsByClassName("ldr")[0]
var sdr = tr.getElementsByClassName("sdr")[0]
var diff = tr.getElementsByClassName("master_diff")[0]
diff.value = parseInt(ldr.value) + parseInt(sdr.value)
};
for (var i = 0; i < inputs.length; i++) {
inputs[i].addEventListener('change', summDiff, false);
}
<form action="" method="post">
<table class="table-responsive">
<thead>
<tr>
<th style="width: 10%;">Task Name</th>
<th style="width: 10%;">Task Code</th>
<th style="width: 10%;">LDR</th>
<th style="width: 10%;">SDR</th>
<th style="width: 30%;">Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>task 1</td>
<td>0001</td>
<td>
<input type="text" class="form-control master ldr inputs" name="ldr[]" value="" placeholder="" autocomplete="off">
</td>
<td>
<input type="text" class="form-control master sdr inputs" name="sdr[]" value="" placeholder="" autocomplete="off">
</td>
<td>
<input type="number" class="form-control master master_diff" name="master_diff[]" readonly />
</td>
<td>
<input type="hidden" name="master[]" value="1" />
</td>
</tr>
<tr>
<td>task 2</td>
<td>0002</td>
<td>
<input type="text" class="form-control master ldr inputs" name="ldr[]" value="" placeholder="" autocomplete="off">
</td>
<td>
<input type="text" class="form-control master sdr inputs" name="sdr[]" value="" placeholder="" autocomplete="off">
</td>
<td>
<input type="number" class="form-control master master_diff" name="master_diff[]" readonly />
</td>
<td>
<input type="hidden" name="master[]" value="2" />
</td>
</tr>
<tr>
<td>task 3</td>
<td>0003</td>
<td>
<input type="text" class="form-control master ldr inputs" name="ldr[]" value="" placeholder="" autocomplete="off">
</td>
<td>
<input type="text" class="form-control master sdr inputs" name="sdr[]" value="" placeholder="" autocomplete="off">
</td>
<td>
<input type="number" class="form-control master master_diff" name="master_diff[]" readonly />
</td>
<td>
<input type="hidden" name="master[]" value="3" />
</td>
</tr>
</tbody>
</table>
<div class="pull-right">
<input type="submit" class="btn btn-primary" name="mastertask" placeholder="Assign"/>
</div>
</form>

Submitting Dynamic Form Fields to mysql via PHP

I have created a dynamic form and I am trying to send the form data to mysql through PHP but its not working. Data is not getting sent even from the very first row without adding a dynamic row. I'm new to this topic, so I'm out of ideas to solve it. How can I make this form a correct one and send accurate data to mysql?
In my form I have 3 fields that are not dynamic.
Here is the form code:
<form name="newbillform" method="POST" action="save_purchase_details.php">
<table style=" border:1px solid black" cellpadding="5px" cellspacing="0px" align="center" border="0">
<tr>
<td colspan="4" style="background:#0066FF; color:#FFFFFF; fontsize:20px" align="center">
ADD NEW PURCHASE RECORD
</td>
</tr>
<tr>
<td>Date:</td>
<td>
<input type="date" name="p_date"/>
</td>
</tr>
<tr>
<td>Invoice Number:</td>
<td>
<input type="text" name="invoice_no" size="50">
</td>
</tr>
<tr>
<td>Balance:</td>
<td>
<input type="text" name="balance" size="50">
</td>
</tr>
</table>
<h2 style="padding-left:10px;">Enter Product Details Below:-</h2>
<table id="product_details" style="margin-top:8px;" align='center' border='1' width="900px">
<tr id="row1">
<td>
<input type="text" name="qty[]" value="" placeholder="Quantity" size="6">
</td>
<td>
<input type="text" name="pack[]" value="" placeholder="Pack" size="6">
</td>
<td>
<input type="text" name="item_name[]" value="" placeholder="Item Name" size="16">
</td>
<td>
<input type="text" name="batch[]" value="" placeholder="Batch" size="6">
</td>
<td>
<input type="text" name="expiry[]" value="" placeholder="Expiry" size="6">
</td>
<td>
<input type="text" name="mrp[]" value="" placeholder="M.R.P" size="6">
</td>
<td>
<input type="text" name="rate[]" value="" placeholder="Rate" size="6">
</td>
<td>
<input type="text" name="vat[]" value="" placeholder="VAT" size="6">
</td>
<td>
<input type="text" name="discount[]" value="" placeholder="Discount" size="6">
</td>
<td>
<input type="button" class="button-add-row" onclick="add_row();" value="ADD ROW" size="8">
</td>
</tr>
</table>
<center>
<input type="submit" name="submit_row" value="SUBMIT">
</center>
</form>
Here is the javascript code:
<script type="text/javascript">
function add_row()
{
$rowno = $("#product_details tr").length;
$rowno = $rowno + 1;
$("#product_details tr:last").after("<tr id='row"+$rowno+"'><td><input type='text' name='qty[]' placeholder='Quantity' size='6'></td><td><input type='text' name='pack[]' placeholder='Pack' size='6'></td><td><input type='text' placeholder='Item Name' name='item_name[]' size='16'></td><td><input type='text' name='batch[]' placeholder='Batch' size='6'></td><td><input type='text' name='expiry[]' placeholder='Expiry' size='6'></td><td><input type='text' name='mrp[]' placeholder='M.R.P' size='6'></td><td><input type='text' name='rate[]' placeholder='Rate' size='6'></td><td><input type='text' name='vat[]' placeholder='VAT' size='6'></td><td><input type='text' name='discount[]' placeholder='Discount' size='6'></td><td><input type='button' class='button-add-row' value='DELETE' onclick=delete_row('row"+$rowno+"')></td></tr>");
}
function delete_row(rowno)
{
$('#'+rowno).remove();
}
</script>
Here is the PHP code:
<?php
$connect = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("store_records",$connect) or die(mysql_error());
if(isset($_POST['submit_row']))
{
$amount;
$grand_total;
for($i = 0; $i < count($_POST['item_name']); $i++)
{
$qty = $_POST['qty'][$i];
$p_date = $_POST['p_date'];
$invoice_no = $_POST['invoice_no'];
$balance = $_POST['balance'];
$pack = $_POST['pack'][$i];
$item_name = $_POST['item_name'][$i];
$batch = $_POST['batch'][$i];
$expiry = $_POST['expiry'][$i];
$mrp = $_POST['mrp'][$i];
$rate = $_POST['rate'][$i];
$vat = $_POST['vat'][$i];
$discount = $_POST['discount'][$i];
$amount = $balance+($qty*$rate)-$discount;
$grand_total = $amount+(($amount*$vat)/100);
$query =mysql_query("insert into bill_records values('', '$p_date', '$invoice_no', '$balance', '$qty','$pack','$item_name', '$batch', '$expiry', '$mrp', '$rate', '$vat', '$discount', '$amount', '$grand_total')");
}
}
?>
It would be of great help. Thank You..

Adding radio input dynamically doesn't work with others with the same name

Imagine the problem: I have a form with 3 radio inputs with the same name and i have a button which adds another radio input with the same name as those first 3. The problem is that after i add another radio field via the button the radio doesn't cooperate with those first 3 radios(it is like it adds another one group for those radios).
To see the problem press few times "Add Line" button, than play with radio buttons. The first 3 default radios are in one group and the added one are in different group.
Can someone tell me how to make all of those radios cooperate with each others(be like in one group)?
The code:
function addAnswer(value) {
thebutton = value;
console.log(value);
table = document.getElementById("thetable");
row = table.insertRow(table.rows.length);
cell1 = row.insertCell(0);
cell2 = row.insertCell(1);
cell1.innerHTML = '<input type="text" name="answer[]" required style="width: 100%;" placeholder="Wpisz tutaj odpowiedź">';
cell2.innerHTML = '<input type="radio" value="' + value + '" name="correct">';
document.getElementById("addbutton").value = parseInt(value) + 1;
}
<table style="width: 100%;" id="thetable">
<form action="" method="POST">
<tr>
<td style="width: 80%;">Odpowiedź</td>
<td style="width: 20%;">Poprawna</td>
</tr>
<tr>
<td>
<input type="text" name="answer[]" required style="width: 100%;" placeholder="Wpisz tutaj odpowiedź">
</td>
<td>
<input type="radio" id="radio0" name="correct" value="0">
</td>
</tr>
<tr>
<td>
<input type="text" name="answer[]" required style="width: 100%;" placeholder="Wpisz tutaj odpowiedź">
</td>
<td>
<input type="radio" id="radio1" name="correct" value="1">
</td>
</tr>
<tr>
<td>
<input type="text" name="answer[]" required style="width: 100%;" placeholder="Wpisz tutaj odpowiedź">
</td>
<td>
<input type="radio" id="radio2" name="correct" value="2">
</td>
</tr>
</table>
<button type="button" value="3" id="addbutton" onclick="addAnswer(this.value)" style="width: auto; height: auto;">Add line</button>
<input type="hidden" name="questionId" value="<?php echo $id[0]['id']; ?>">
</form>
If you switch these two lines, the table is inside the form. Perhaps that will solve your issue:
<table style="width: 100%;" id="thetable">
<form action="" method="POST">
function addAnswer(value) {
thebutton = value;
console.log(value);
table = document.getElementById("thetable");
row = table.insertRow(table.rows.length);
cell1 = row.insertCell(0);
cell2 = row.insertCell(1);
cell1.innerHTML = '<input type="text" name="answer[]" required style="width: 100%;" placeholder="Wpisz tutaj odpowiedź">';
cell2.innerHTML = '<input type="radio" value="' + value + '" name="correct">';
document.getElementById("addbutton").value = parseInt(value) + 1;
}
<form action="" method="POST">
<table style="width: 100%;" id="thetable">
<tr>
<td style="width: 80%;">Odpowiedź</td>
<td style="width: 20%;">Poprawna</td>
</tr>
<tr>
<td>
<input type="text" name="answer[]" required style="width: 100%;" placeholder="Wpisz tutaj odpowiedź">
</td>
<td>
<input type="radio" id="radio0" name="correct" value="0">
</td>
</tr>
<tr>
<td>
<input type="text" name="answer[]" required style="width: 100%;" placeholder="Wpisz tutaj odpowiedź">
</td>
<td>
<input type="radio" id="radio1" name="correct" value="1">
</td>
</tr>
<tr>
<td>
<input type="text" name="answer[]" required style="width: 100%;" placeholder="Wpisz tutaj odpowiedź">
</td>
<td>
<input type="radio" id="radio2" name="correct" value="2">
</td>
</tr>
</table>
<button type="button" value="3" id="addbutton" onclick="addAnswer(this.value)" style="width: auto; height: auto;">Add line</button>
<input type="hidden" name="questionId" value="<?php echo $id[0]['id']; ?>">
</form>

Populating a drop down box with inputs from database that'd lead to another populated page

So I volunteered to create a user form at work and thought I'd add a fun little twist and do it in HTML/CSS/PHP/mySQL rather than MS word.
Basically, this is a form I'll be using to add and delete user from my database. I've already finished the initial form, created a PHP file to save everything in my database and linked it properly.
My question is, how do I create a page with a drop down list of all Names/Last Names/IDs where the person browsing it could click "submit" and get all the information about the user?
I've been googling for hours now, but to no avail as it seems that some people have similar problems, but are missing some large puzzle piece that I need as well.
I know it sounds a bit confusing, so here's my code so that you can get a better idea:
HTML:
#charset "UTF-8";
table,
th,
td {} table {
border-collapse: collapse;
}
td {
padding: 3px;
}
input[type="text"],
textarea {
background-color: #F8FCFF;
border: 2px solid #eeeeee;
color: #333333;
font-size: 0.9em;
font-style: normal;
font-weight: 400;
font-family: Tahoma;
Helvetica;
}
body {
background-color: #e6e6e6;
margin: 0 auto;
}
f {
font-style: normal;
font-weight: 550;
font-family: sans-serif;
source-sans-pro;
}
bigbold {
font-style: normal;
font-weight: bold;
font-size: 20px;
font-family: sans-serif;
source-sans-pro;
}
info {
font-style: normal;
font-weight: bold;
font-family: sans-serif;
source-sans-pro;
}
.tr-top {
border-top: 1pt solid black;
}
.tr-left {
border-left: 1pt solid black;
}
.td-left {
border-left: 1pt solid black;
width: 35%;
}
.checkboxes label {
display: block;
float: left;
padding-right: 10px;
white-space: nowrap;
}
.checkboxes input {
vertical-align: middle;
}
.checkboxes label span {
vertical-align: middle;
}
#body1 {
width: 1000px;
background: #fff;
height: 100%;
}
#wrapper {
max-width: 1000px;
height: 100%;
background: #fff;
margin: 0px auto 0;
padding: 20px;
}
#colour {
background: #C6DEFF;
}
</style>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled D
<!--#include file="NewUser_get.php" -->
ocument</title>
<link href="Untitled-4.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--<div id="body1">-->
<div id="wrapper">
<div id="head">
<form action="NewUser_get.php" method="POST">
<table style="width:1000px">
<tr>
<td width=90%>
<f>Request date:</f>
<br>
<input type="date" name="RequestDate">
</td>
<td width=10%>
<f>Requested by:</f>
<br>
<input type="text" style="width: 166px;" name="RequestBy">
</td>
</tr>
</table>
<br>
<div id="colour">
<info>
<center>New User Info</center>
</info>
</div>
<br>
<table style="width:100%">
<tr>
<td>
<f>Employee's last name: </f>
<input type="text" placeholder="Click to type" name="LastName">
</td>
<td>
<f>First name
<input type="text" placeholder="Click to type" name="FirstName">
</td>
<td>
<f>Middle name
<input type="text" placeholder="Click to type" name="MiddleName">
</td>
<td>
<f>Employment type
<select name="EmploymentType">
<option value="Permanent">Permanent</option>
<option value="Temporary">Temporary</option>
<option value="Contractor">Contractor</option>
<option value="Placement">Placement</option>
<option value="Other">Other</option>
</select>
</td>
<td width="80px">
<f> Gender</f>
<br>
<label for="GenderMale">
<input type="checkbox" name="GenderMale" value="Yes" /> <span>M</span>
</label>
<label for="GenderFemale">
<input type="checkbox" name="GenderFemale" value="Yes" /> <span>F</span>
</label>
</td>
</tr>
<tr>
<td>
<f>Department </f>
<br>
<input type="text" placeholder="Click to type" name="Department1">
</td>
<td>
<f>Job title </f>
<input type="text" placeholder="Click to type" name="JobTitle">
</td>
<td>
<f>Manager's name </f>
<input type="text" placeholder="Click to type" name="ManagerName">
</td>
<td>
<f>Start date </f>
<br>
<input type="date" placeholder="Click to type" name="StartDate">
</td>
<td>
<f>Finish date </f>
<input type="date" style="width: 166px;" name="FinishDate">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>Full address:</f>
<br>
<input type="text" style="width: 992px;" placeholder="Click to type, Address/ P.O. Box, City, Street, Post code" name="FullAddress">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>User Group / Profile to Use:</f>
<input type="text" style="width: 325px;" placeholder="Click to type, e.g. same as John, Accounts" name="UserGroup">
</td>
<td>
<f>Distribution Groups to be included:</f>
<input type="text" style="width: 325px;" placeholder="Click to type, e.g. Staff, Internal, External" name="DistributionGroup">
</td>
<td>
<f>Shared Drive Access:</f>
<input type="text" style="width: 325px;" placeholder="Click to type" name="SharedDriveAccess">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>Permissions on shared drives (in detail):</f>
<br>
<input type="text" style="width: 993px;" placeholder="Click to type, e.g. Marketing drive 'read only, Technical drive 'Full Access'" name="Permissions">
</td>
</tr>
</table>
<br>
<div id="colour">
<info>
<center>Additional Info</center>
</info>
</div>
<br>
<div class="checkboxes">
<table style="width:100%">
<tr>
<td width="%50">
<bigbold>List of required items (Tick the box next to an item):</bigbold>
</td>
<td>&nbsp</td>
<td class="td-left" width="%50">
<bigbold>List of required software/drive access:</bigbold>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td class="td-left">
<info> Drives:</info>
</td>
<td>
<info> Software:</info>
</td>
</tr>
<tr>
<td>
<label for="iPad">
<input type="checkbox" name="iPad" value="Yes"> <span><f>iPad + case</f></span>
</label>
</td>
<td>
<label for="Mouse">
<input type="checkbox" name="Mouse" value="Yes"> <span><f>Mouse</f></span>
</label>
</td>
<td class="td-left">
<label for="Sales">
<input type="checkbox" name="Sales" value="Yes"><span><f>Sales</f></span>
</label>
</td>
<td>
<label for="Salesforce">
<input type="checkbox" name="Salesforce" value="Yes"> <span><f>Salesforce</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="iPhone">
<input type="checkbox" name="iPhone" value="Yes"> <span><f>iPhone + case</f></span>
</label>
</td>
<td>
<label for="Laptopb">
<input type="checkbox" name="Laptopb" value="Yes"> <span><f>Laptop bag</f></span>
</label>
</td>
<td class="td-left">
<label for="Marketing">
<input type="checkbox" name="Marketing" value="Yes"> <span><f>Marketing</f></span>
</label>
</td>
<td>
<label for="VPN">
<input type="checkbox" name="VPN" value="Yes"> <span><f>VPN</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Laptop">
<input type="checkbox" name="Laptop" value="Yes"> <span><f>Laptop</f></span>
</label>
</td>
<td>
<label for="Dphone">
<input type="checkbox" name="Dphone" value="Yes"> <span><f>Desk phone</f></span>
</label>
</td>
<td class="td-left">
<label for="General">
<input type="checkbox" name="General" value="Yes"> <span><f>General</f></span>
</label>
</td>
<td>
<label for="Terminal">
<input type="checkbox" name="Terminal" value="Yes"> <span><f>Terminal server</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Desktop">
<input type="checkbox" name="Desktop" value="Yes" /> <span><f>Desktop</f></span>
</label>
</td>
<td>
<label for="Printerw">
<input type="checkbox" name="Printerw" value="Yes"> <span><f>Printer (work)</f></span>
</label>
</td>
<td class="td-left">
<label for="CAD">
<input type="checkbox" name="CAD" value="Yes"> <span><f>CAD</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Printerh">
<input type="checkbox" name="Printerh" value="Yes"> <span><f>Printer (home)</f></span>
</label>
</td>
<td>
<label for="Dongle">
<input type="checkbox" name="Dongle" value="Yes"> <span><f>Dongle</f></span>
</label>
</td>
<td class="td-left">
<label for="Finance">
<input type="checkbox" name="Finance" value="Yes"> <span><f>Finance</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Monitor">
<input type="checkbox" name="Monitor" value="Yes"> <span><f>Monitor</f></span>
</label>
</td>
<td>
<label for="MiFi">
<input type="checkbox" name="Mifi" value="Yes"> <span><f>MiFi (Mobile Wifi)</f></span>
</label>
</td>
<td class="td-left">
<label for="Accounts">
<input type="checkbox" name="Accounts" value="Yes"> <span><f>Accounts</f></span>
</label>
</td>
<td></td>
</tr>
<tr>
<td>
<label for="Keyboard">
<input type="checkbox" name="Keyboard" value="Yes"> <span><f>Keyboard</f></span>
</label>
</td>
<td></td>
<td class="td-left"></td>
<td></td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</table>
<div id="colour">
<center>
<info>Miscellaneous:</info>
</center>
</div>
<br>
<table style="width:100%">
<tr>
<td>
<f>Should the predecessor's email be assigned to this user?</f>
</td>
<td>
<label for="Pemail">
<input type="checkbox" name="Pemail" value="Yes"> <span><f>Yes</f></span>
</label>
</td>
</tr>
<tr class="tr-top">
<td>
<f>Is the user replacing someone else from the staff or is he/she a completely new employee?</f>
</td>
<td>
<label for="Replacement">
<input type="checkbox" name="Replacement" value="Yes"> <span><f>Replacement</f></span>
</label>
</td>
<td>
<label for="NewUser">
<input type="checkbox" name="NewUser" value="Yes"> <span><f>New user</f></span>
</label>
</td>
</tr>
</table>
<br>
<textarea name="AddRequirements" style="width:1000px;" placeholder="Please continue here for any other extra requirements e.g. need of a special signature, software, hardware etc. or needed access to another user’s files and documents, or assign another user’s email profile to this user so they inherit all files and folders form the old user."></textarea>
<!--<input type='hidden' name='articleid' id='articleid' value='<? echo $_GET["id"]; ?>' /> -->
<input type="submit">
</form>
</div>
</div>
</body>
</html>
PHP:
<?php
if( $_POST )
{
$conn = mysqli_connect("myhost","myuser","mypassword", "mydb");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$RequestBy = $_POST['RequestBy'];
$FirstName = $_POST['FirstName'];
$MiddleName = $_POST['MiddleName'];
$LastName = $_POST['LastName'];
$Desktop = $_POST['Desktop'];
$EmploymentType = $_POST['EmploymentType'];
$GenderMale = $_POST['GenderMale'];
$GenderFemale = $_POST['GenderFemale'];
$Department1 = $_POST['Department1'];
$JobTitle = $_POST['JobTitle'];
$ManagerName = $_POST['ManagerName'];
$FullAddress = $_POST['FullAddress'];
$UserGroup = $_POST['UserGroup'];
$DistributionGroup = $_POST['DistributionGroup'];
$SharedDriveAccess = $_POST['SharedDriveAccess'];
$Permissions = $_POST['Permissions'];
$iPad = $_POST['iPad'];
$Mouse = $_POST['Mouse'];
$Sales = $_POST['Sales'];
$Salesforce = $_POST['Salesforce'];
$iPhone = $_POST['iPhone'];
$Laptopb = $_POST['Laptopb'];
$Marketing = $_POST['Marketing'];
$VPN = $_POST['VPN'];
$Laptop = $_POST['Laptop'];
$Dphone = $_POST['Dphone'];
$General = $_POST['General'];
$Terminal = $_POST['Terminal'];
$Printerw = $_POST['Printerw'];
$CAD = $_POST['CAD'];
$Printerh = $_POST['Printerh'];
$Dongle = $_POST['Dongle'];
$Finance = $_POST['Finance'];
$Monitor = $_POST['Monitor'];
$Mifi = $_POST['Mifi'];
$Accounts = $_POST['Accounts'];
$Keyboard = $_POST['Keyboard'];
$Pemail = $_POST['Pemail'];
$Replacement = $_POST['Replacement'];
$NewUser = $_POST['NewUser'];
$AddRequirements = $_POST['AddRequirements'];
}
$sql= "
INSERT INTO TestTable (RequestBy, FirstName, MiddleName, LastName, Desktop, EmploymentType, GenderMale, GenderFemale, Department1, JobTitle, ManagerName, FullAddress, UserGroup, DistributionGroup, SharedDriveAccess, Permissions, iPad, Mouse, Sales, Salesforce, iPhone, Laptopb, Marketing, VPN, Laptop, Dphone, General, Terminal, Printerw, CAD, Printerh, Dongle, Finance, Monitor, Mifi, Accounts, Keyboard, Pemail, Replacement, NewUser, AddRequirements) VALUES ('$RequestBy', '$FirstName', '$MiddleName', '$LastName', '$Desktop', '$EmploymentType', '$GenderMale', '$GenderFemale', '$Department1', '$JobTitle', '$ManagerName', '$FullAddress', '$UserGroup', '$DistributionGroup', '$SharedDriveAccess', '$Permissions', '$iPad', '$Mouse', '$Sales', '$Salesforce', '$iPhone', '$Laptopb', '$Marketing', '$VPN', '$Laptop', '$Dphone', '$General', '$Terminal', '$Printerw', '$CAD', '$Printerh', '$Dongle', '$Finance', '$Monitor', '$Mifi', '$Accounts', '$Keyboard', '$Pemail', '$Replacement', '$NewUser', '$AddRequirements');";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>
Basically I want to create another page where I could select the user's name, click some button, and then see all the information such as access to "sales" drive, gender, etc. displayed.
Ignore the lack of security measures in the code, it'll be used on a local server by very few and trustworthy people.
If somebody could just guide me on the right path, it'd be much appreciated. Thank you in advance.
It seems to need a bit of AJAX to accomplish this.
At first, you need to make the php file containing the select box. Note, that you have to include jquery at html .
In select_user.php
<?php
//Connection to database
$connection = mysqli_connect('localhost', 'root', 'your_password', 'your_database');
mysqli_set_charset($connection, 'utf8');
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
//Simple query to populate the select box
$query = "SELECT id, FirstName, LastName FROM TestTable ORDER BY FirstName ASC, LastName ASC, id ASC;";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) > 0) { //If there are records in database table
echo '<select id="user" name="user">';
while ($row = mysqli_fetch_array($result)) {
echo '<option value="'.$row['id'].'">'.$row['FirstName'].' '.$row['LastName'].'</option>';
}
echo '</select>';
} else {
echo '<p class="alert">There are no data to select from.</p>';
}
?>
<div id="results">
</div>
Then you have to write some AJAX asking the server to fetch the user with the selected id (note that normally you have to be very careful with user inputs).
At the bottom of select_user.php
<script>
$(document).ready(function(){
//Each time that the value of select box changes then make an ajax call and bring the user details
$('#user').on('change', function() {
var id = $(this).val();
$.ajax({
async: false,
url: "ajax.php",
type: "POST",
data: {id : id},
dataType: "json",
success: function(data) {
//Check if data is empty or make some other validations
var firstName = data.FirstName;
var lastName = data.LastName;
var fullAddress = data.FullAddress;
var permissions = data.Permissions;
var str = '<p>Name: '+firstName+' '+lastName+' '+fullAddress+' '+permissions+'</p>';
//Replace content at #results div
$('#results').innerHtml(str);
}
});
}
}
</script>
Finally, you have to create the file ajax.php which contains the query that brings back the details of the selected user.
In file ajax.php
<?php
//This is ajax.php
//Connection to database
$connection = mysqli_connect('localhost', 'root', 'your_password', 'your_database');
mysqli_set_charset($connection, 'utf8');
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
$id = $_POST['id'];
//Never trust input from users
//Sanitize and validate variables
//Use prepared statemends or PDO
$query = "SELECT id, FirstName, LastName, FullAddress, Permissions FROM TestTable WHERE id = '$id';";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_array($result);
$json['id'] = $row['id'];
$json['firstName'] = $row['FirstName'];
$json['lastName'] = $row['LastName'];
$json['fullAddress'] = $row['FullAddress'];
$json['permisions'] = $row['Permissions'];
echo json_encode($json);
mysqli_close($connection);
?>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<?php
//Connection to database
$connection = mysqli_connect("*****************","***********","****", "******");
mysqli_set_charset($connection, 'utf8');
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
//Simple query to populate the select box
$query = "SELECT id, FirstName, LastName FROM TestTable ORDER BY FirstName ASC, LastName ASC, id ASC;";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) > 0) { //If there are records in database table
echo '<select id="user" name="user">';
while ($row = mysqli_fetch_array($result)) {
echo '<option value="'.$row['id'].'">'.$row['FirstName'].' '.$row['LastName'].'</option>';
}
echo '</select>';
} else {
echo '<p class="alert">There are no data to select from.</p>';
}
?>
<div id="results">
</div>
<script>
$(document).ready(function(){
//Each time that the value of select box changes then make an ajax call and bring the user details
$('#user').on('change', function() {
var id = $(this).val();
$.ajax({
async: false,
url: "ajax.php",
type: "POST",
data: {id : id},
dataType: "json",
success: function(data) {
//Check if data is empty or make some other validations
var firstName = data.FirstName;
var lastName = data.LastName;
var fullAddress = data.FullAddress;
var permissions = data.Permissions;
var str = '<p>Name: '+firstName+' '+lastName+' '+fullAddress+' '+permissions+'</p>';
//Replace content at #results div
$('#results').innerHtml(str);
}
});
}
}
</script>
<div id="results">
</div>
This is the select_user.php file:
<?php
//Connection to database
$connection = mysqli_connect("****","****","****", "***");
mysqli_set_charset($connection, 'utf8');
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
//Simple query to populate the select box
$query = "SELECT id, FirstName, LastName FROM TestTable ORDER BY FirstName ASC, LastName ASC, id ASC;";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) > 0) { //If there are records in database table
echo '<select id="user" name="user">';
while ($row = mysqli_fetch_array($result)) {
echo '<option value="'.$row['id'].'">'.$row['FirstName'].' '.$row['LastName'].'</option>';
}
echo '</select>';
} else {
echo '<p class="alert">There are no data to select from.</p>';
}
?>
<div id="results">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
$(document).ready(function(){
//Each time that the value of select box changes then make an ajax call and bring the user details
$('#user').on('change', function() {
var id = $(this).val();
$.ajax({
async: false,
url: "ajax.php", //Tried changing this to domainname.com/ajax.php but that didn't change anything.
type: "POST",
data: {id : id},
dataType: "json",
success: function(data) {
//Check if data is empty or make some other validations
var firstName = data.FirstName;
var lastName = data.LastName;
var fullAddress = data.FullAddress;
var permissions = data.Permissions;
var str = '<p>Name: '+firstName+' '+lastName+' '+fullAddress+' '+permissions+'</p>';
//Replace content at #results div
$('#results').innerHtml(str);
}
});
}
}
</script>
<div id="results">
</div>
This is ajax.php:
<?php
//This is ajax.php
//Connection to database
$connection = mysqli_connect("******","******","*******", "*******");
mysqli_set_charset($connection, 'utf8');
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
$id = $_POST['id'];
//Never trust input from users
//Sanitize and validate variables
//Use prepared statemends or PDO
$query = "SELECT id, FirstName, LastName, FullAddress, Permissions FROM TestTable WHERE id = '$id';";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_array($result);
$json['id'] = $row['id'];
$json['firstName'] = $row['FirstName'];
$json['lastName'] = $row['LastName'];
$json['fullAddress'] = $row['FullAddress'];
$json['permisions'] = $row['Permissions'];
echo json_encode($json);
mysqli_close($connection);
?>
This is the HTML.
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<meta charset="utf-8">
<title>Untitled D
<!--#include file="NewUser_get.php" -->
ocument</title>
<link href="Untitled-4.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--<div id="body1">-->
<div id="wrapper">
<div id="head">
<center>
<img src="http://www.rwc.com/wp-content/themes/RWC_Global/assets/images/logo.png">
</center>
<form action="NewUser_get.php" method="POST">
<table style="width:1000px">
<tr>
<td width=90%>
<f>Request date:</f>
<br>
<input type="date" name="RequestDate">
</td>
<td width=10%>
<f>Requested by:</f>
<br>
<input type="text" style="width: 166px;" name="RequestBy">
</td>
</tr>
</table>
<br>
<div id="colour">
<info>
<center>New User Info</center>
</info>
</div>
<br>
<table style="width:100%">
<tr>
<td>
<f>Employee's last name: </f>
<input type="text" placeholder="Click to type" name="LastName">
</td>
<td>
<f>First name
<input type="text" placeholder="Click to type" name="FirstName">
</td>
<td>
<f>Middle name
<input type="text" placeholder="Click to type" name="MiddleName">
</td>
<td>
<f>Employment type
<select name="EmploymentType">
<option value="Permanent">Permanent</option>
<option value="Temporary">Temporary</option>
<option value="Contractor">Contractor</option>
<option value="Placement">Placement</option>
<option value="Other">Other</option>
</select>
</td>
<td width="80px">
<f> Gender</f>
<br>
<label for="GenderMale">
<input type="checkbox" name="GenderMale" value="Yes" /> <span>M</span>
</label>
<label for="GenderFemale">
<input type="checkbox" name="GenderFemale" value="Yes" /> <span>F</span>
</label>
</td>
</tr>
<tr>
<td>
<f>Department </f>
<br>
<input type="text" placeholder="Click to type" name="Department1">
</td>
<td>
<f>Job title </f>
<input type="text" placeholder="Click to type" name="JobTitle">
</td>
<td>
<f>Manager's name </f>
<input type="text" placeholder="Click to type" name="ManagerName">
</td>
<td>
<f>Start date </f>
<br>
<input type="date" placeholder="Click to type" name="StartDate">
</td>
<td>
<f>Finish date </f>
<input type="date" style="width: 166px;" name="FinishDate">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>Full address:</f>
<br>
<input type="text" style="width: 992px;" placeholder="Click to type, Address/ P.O. Box, City, Street, Post code" name="FullAddress">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>User Group / Profile to Use:</f>
<input type="text" style="width: 325px;" placeholder="Click to type, e.g. same as John, Accounts" name="UserGroup">
</td>
<td>
<f>Distribution Groups to be included:</f>
<input type="text" style="width: 325px;" placeholder="Click to type, e.g. Staff, Internal, External" name="DistributionGroup">
</td>
<td>
<f>Shared Drive Access:</f>
<input type="text" style="width: 325px;" placeholder="Click to type" name="SharedDriveAccess">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>Permissions on shared drives (in detail):</f>
<br>
<input type="text" style="width: 993px;" placeholder="Click to type, e.g. Marketing drive 'read only, Technical drive 'Full Access'" name="Permissions">
</td>
</tr>
</table>
<br>
<div id="colour">
<info>
<center>Additional Info</center>
</info>
</div>
<br>
<div class="checkboxes">
<table style="width:100%">
<tr>
<td width="%50">
<bigbold>List of required items (Tick the box next to an item):</bigbold>
</td>
<td>&nbsp</td>
<td class="td-left" width="%50">
<bigbold>List of required software/drive access:</bigbold>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td class="td-left">
<info> Drives:</info>
</td>
<td>
<info> Software:</info>
</td>
</tr>
<tr>
<td>
<label for="iPad">
<input type="checkbox" name="iPad" value="Yes"> <span><f>iPad + case</f></span>
</label>
</td>
<td>
<label for="Mouse">
<input type="checkbox" name="Mouse" value="Yes"> <span><f>Mouse</f></span>
</label>
</td>
<td class="td-left">
<label for="Sales">
<input type="checkbox" name="Sales" value="Yes"><span><f>Sales</f></span>
</label>
</td>
<td>
<label for="Salesforce">
<input type="checkbox" name="Salesforce" value="Yes"> <span><f>Salesforce</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="iPhone">
<input type="checkbox" name="iPhone" value="Yes"> <span><f>iPhone + case</f></span>
</label>
</td>
<td>
<label for="Laptopb">
<input type="checkbox" name="Laptopb" value="Yes"> <span><f>Laptop bag</f></span>
</label>
</td>
<td class="td-left">
<label for="Marketing">
<input type="checkbox" name="Marketing" value="Yes"> <span><f>Marketing</f></span>
</label>
</td>
<td>
<label for="VPN">
<input type="checkbox" name="VPN" value="Yes"> <span><f>VPN</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Laptop">
<input type="checkbox" name="Laptop" value="Yes"> <span><f>Laptop</f></span>
</label>
</td>
<td>
<label for="Dphone">
<input type="checkbox" name="Dphone" value="Yes"> <span><f>Desk phone</f></span>
</label>
</td>
<td class="td-left">
<label for="General">
<input type="checkbox" name="General" value="Yes"> <span><f>General</f></span>
</label>
</td>
<td>
<label for="Terminal">
<input type="checkbox" name="Terminal" value="Yes"> <span><f>Terminal server</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Desktop">
<input type="checkbox" name="Desktop" value="Yes" /> <span><f>Desktop</f></span>
</label>
</td>
<td>
<label for="Printerw">
<input type="checkbox" name="Printerw" value="Yes"> <span><f>Printer (work)</f></span>
</label>
</td>
<td class="td-left">
<label for="CAD">
<input type="checkbox" name="CAD" value="Yes"> <span><f>CAD</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Printerh">
<input type="checkbox" name="Printerh" value="Yes"> <span><f>Printer (home)</f></span>
</label>
</td>
<td>
<label for="Dongle">
<input type="checkbox" name="Dongle" value="Yes"> <span><f>Dongle</f></span>
</label>
</td>
<td class="td-left">
<label for="Finance">
<input type="checkbox" name="Finance" value="Yes"> <span><f>Finance</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Monitor">
<input type="checkbox" name="Monitor" value="Yes"> <span><f>Monitor</f></span>
</label>
</td>
<td>
<label for="MiFi">
<input type="checkbox" name="Mifi" value="Yes"> <span><f>MiFi (Mobile Wifi)</f></span>
</label>
</td>
<td class="td-left">
<label for="Accounts">
<input type="checkbox" name="Accounts" value="Yes"> <span><f>Accounts</f></span>
</label>
</td>
<td></td>
</tr>
<tr>
<td>
<label for="Keyboard">
<input type="checkbox" name="Keyboard" value="Yes"> <span><f>Keyboard</f></span>
</label>
</td>
<td></td>
<td class="td-left"></td>
<td></td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</table>
<div id="colour">
<center>
<info>Miscellaneous:</info>
</center>
</div>
<br>
<table style="width:100%">
<tr>
<td>
<f>Should the predecessor's email be assigned to this user?</f>
</td>
<td>
<label for="Pemail">
<input type="checkbox" name="Pemail" value="Yes"> <span><f>Yes</f></span>
</label>
</td>
</tr>
<tr class="tr-top">
<td>
<f>Is the user replacing someone else from the staff or is he/she a completely new employee?</f>
</td>
<td>
<label for="Replacement">
<input type="checkbox" name="Replacement" value="Yes"> <span><f>Replacement</f></span>
</label>
</td>
<td>
<label for="NewUser">
<input type="checkbox" name="NewUser" value="Yes"> <span><f>New user</f></span>
</label>
</td>
</tr>
</table>
<br>
<textarea name="AddRequirements" style="width:1000px;" placeholder="Please continue here for any other extra requirements e.g. need of a special signature, software, hardware etc. or needed access to another user’s files and documents, or assign another user’s email profile to this user so they inherit all files and folders form the old user."></textarea>
<!--<input type='hidden' name='articleid' id='articleid' value='<? echo $_GET["id"]; ?>' /> -->
<input type="submit">
</form>
</div>
</div>
</body>
</html>
Sorry for the late reply, was a bit caught up in things. Thank you for all the help, it just feels like I can't do much at this point because I quite literally can't understand where the issue lies.

Conflict in including of a file

I'm trying to include a file which generates 2 random numbers that needs to be add or what we call captcha. I have two logins: one that requires employee id, birthdate, and the captcha answer(Which I call the easy login). While the other one requires your first name, last name, birthdate, and captcha(I call it the standard login). So I have two radio buttons for the user to choose whether an easy login or standard login. So I'm encountering this problem when you choose a login then you need to answer the captcha (The captcha sends sessions for its answer) so whats happening right know is that the captcha in the easy login is always being override by the captcha in the standard login. What I thought that I would do is set a condition where if the radio button is selected (easy login) then thats the time it will be included. But I don't know how to do that.
Here is the captcha code:
captcha.php
<?php
session_start();
$n1=rand(1,6); //Generate First number between 1 and 6
$n2=rand(5,9); //Generate Second number between 5 and 9
$answer=$n1+$n2;
$math = "What is ".$n1." + ".$n2." ? ";
$_SESSION['vercode'] = $answer;
print $math;
?>
Then here is the code for my interface:
index.php
<SCRIPT TYPE="text/javascript">
function toggleTables(which)
{
if(which == "0") {
document.getElementById('standard').style.display = "table";
document.getElementById('customize').style.display = "none";
}
if(which == "1") {
document.getElementById('customize').style.display = "table";
document.getElementById('standard').style.display = "none";
}
}
</SCRIPT>
</head>
<body style="background: url(../images/background.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;" >
<?php include('../include/logoheader.php'); ?>
<div class="row">
<div class="twelve columns">
<hr />
</div>
</div>
<div class="row">
<div class="two columns">
</div>
<div class="eight columns">
<div class="content">
<?php include('../include/retain-empid.php'); ?>
<br>
<input name="radio" type="radio" id="customize_1" onClick="toggleTables('0')" value="radio" /><font color="white">Standard Login</font>
<input name="radio" type="radio" id="customize_0" onClick="toggleTables('1')" value="radio" checked="checked"/><font color="white">Easy Login</font>
<form name="loginform" action="login_exec.php" method="post" >
<center><?php include('../function/login_errmsg.php'); ?></center>
<table width="100%" class="imagetable" cellpadding="0" cellspacing="0" id="customize">
<tr>
<th colspan="4">
Easy Log-in For Registered Convergys Employees
</th>
</tr>
<tr>
<td align="right">
<label>Employee Number</label>
</td>
<td>
<input type="text" placeholder="Employee Number" name="txt_EmpID" autoComplete="off" value=<?php echo $value; ?> >
</td>
<td align="right">
<label>Birthday</label>
</td>
<td>
<input type="date" class="" placeholder="Birthday" id="txt_BDate" name="txt_BDate" autoComplete="off" maxlength = "10"
style ="width:170px;"/>
</td>
</tr>
<tr>
<td align="right">
<label class="labels" align="center">
<strong>
</strong>
</label>
</td>
<td>
<?php
include ('../include/mathcaptcha.php');
?>
</td>
<td>
<input name="captcha" type="text" placeholder="Answer to math question">
</td>
<td>
</td>
<td>
<input type="submit" id="submit" name="btn_refer" class="btn" value="Submit"
style=" width: 170px; height: 30px; font-size: 11pt; ">
</td>
</tr>
</table>
</form>
<form action="otherlogin_exec.php" method="post">
<table width="100%" class="imagetable" cellpadding="0" cellspacing="0" id="standard" style="display: none">
<tr>
<th colspan="4">
Standard Log-in For All Registered Users
</th>
</tr>
<tr>
<td align = "right">
<label>First name:</label>
</td>
<td>
<input type="text" placeholder="First Name" name="txtFirstName" autoComplete="off" >
</td>
<td>
<label>Last name:</label>
</td>
<td>
<input type="text" placeholder="Last Name" name="txtLastName" autoComplete="off" >
</td>
</tr>
<tr>
<td>
<label>Birthday:</label>
</td>
<td>
<input type="date" class="" placeholder="Birthday" id="txt_BDate"
name="txtPassword" autoComplete="off" maxlength = "10" style = "width:170px;"/>
</td>
<td>
<label class="labels" align="center">
<strong>
</strong>
</label>
</td>
<td>
<?php
include ('../include/mathcaptcha.php');
?>
</td>
<td>
<input name="captcha" type="text" placeholder="Answer to math question">
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
<input type="submit" id="submit" name="btn_refer" class="btn" value="Submit"
style=" width: 100%; height: 30px; font-size: 11pt; ">
</td>
</tr>
</table>
</form>
</div>
</div>
Make the first line of your file
<?php include_once ('../include/mathcaptcha.php'); ?>
then change the lines from
<td>
<?php
include ('../include/mathcaptcha.php');
?>
</td>
to
<td><?php echo $math;?></td>
and take the print out of the captcha file. PHP doesnt affect the design of pages only the outputted data does which should be altered as needed.

Categories

Resources