How to update stock table after making a sale - php

i'm creating an inventory management system and i can't figure out how to link inventory table with the sales table so that products in inventory table are updated when a sale is made. I'm using MySql
Here's the sold.php, When I sell a product this page save a record in sale table but i want to update manuf table qtyleft row.
<?php require_once('../Connections/bidco.php'); ?>
<?php
mysql_select_db($database_bidco, $bidco);
$query_rsSaletype = "SELECT * FROM saletype ORDER BY type ASC";
$rsSaletype = mysql_query($query_rsSaletype, $bidco) or die(mysql_error());
$row_rsSaletype = mysql_fetch_assoc($rsSaletype);
$totalRows_rsSaletype = mysql_num_rows($rsSaletype);
mysql_select_db($database_bidco, $bidco);
$query_rsCustomercategory = "SELECT * FROM buyertype ORDER BY type ASC";
$rsCustomercategory = mysql_query($query_rsCustomercategory, $bidco) or die(mysql_error());
$row_rsCustomercategory = mysql_fetch_assoc($rsCustomercategory);
$totalRows_rsCustomercategory = mysql_num_rows($rsCustomercategory);
mysql_select_db('invmgt', mysql_connect('localhost','root','dream2014')) or die(mysql_error());
?>
<?php
//Start session
session_start();
//Unset the variables stored in session
unset($_SESSION['SESS_ID']);
unset($_SESSION['SESS_Username']);
unset($_SESSION['SESS_Name']);
?>
<?php
if (isset ($_POST ['Submit']))
{
$da=date("Y-m-d");
$itemname=$_POST['itemname'];
$itemcode=$_POST['itemcode'];
$itemtype=$_POST['itemtype'];
$price=$_POST['unitprice'];
$quantity=$_POST['quantity'];
$ttype=$_POST['select2'];
$ccat=$_POST['select'];
$idate=date("Y-m-d");
mysql_query("INSERT INTO sold_goods (itemname, itemcode, itemtype, unitprice, quantity, transactiontype, customercategory, Date) VALUES ('$itemname', '$itemcode', '$itemtype', '$unitprice', '$quantity', '$ttype', '$ccat', '$idate')");
header("location:sold.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table width="711" height="27" border="0">
<tr>
<td width="216">Manufactured Goods </td>
<td width="152">Sold Goods </td>
<td width="148">Client Details </td>
<td width="167">User Accounts </td>
<td width="167">Home </td>
<td width="167"><div align="right">Logout </div></td>
</tr>
</table>
<p> </p>
<form id="form9" name="form9" method="POST" action="">
<table width="828" height="572" border="1" align="center">
<tr>
<td height="55" colspan="3"><div align="center"><strong>SOLD GOODS </strong></div></td>
</tr>
<tr>
<td height="33" colspan="2">User</td>
<td height="33"><?php date_default_timezone_set('Africa/Nairobi'); echo "Time " . date("h:i:sa");
?></td>
</tr>
<tr>
<td height="14">Customer code
<div align="center"></div></td>
<td height="14">Customer category
<select name="select2">
<?php
do {
?>
<option value="<?php echo $row_rsCustomercategory['type']?>"><?php echo $row_rsCustomercategory['type']?></option>
<?php
} while ($row_rsCustomercategory = mysql_fetch_assoc($rsCustomercategory));
$rows = mysql_num_rows($rsCustomercategory);
if($rows > 0) {
mysql_data_seek($rsCustomercategory, 0);
$row_rsCustomercategory = mysql_fetch_assoc($rsCustomercategory);
}
?>
</select></td>
<td height="14"><?php echo "Date of Transaction " . date("Y/m/d")?></td>
</tr>
<tr>
<td height="15"> </td>
<td height="15"> </td>
<td height="15"> </td>
</tr>
<tr>
<td height="32" colspan="2"><div align="center"><strong>ITEM DETAILS </strong></div></td>
<td width="258" rowspan="3"><div align="center"></div>
<div align="center"></div></td>
</tr>
<tr>
<td width="227" height="23"><div align="right">Item name </div></td>
<td width="321"><input name="itemname" type="text" id=itemname /></td>
</tr>
<tr>
<td><div align="right">Item code </div></td>
<td><input name="itemcode" type="text" id="itemcode" /></td>
</tr>
<tr>
<td><div align="right">Item type </div></td>
<td><input name="itemtype" type="text" id="itemtype" /></td>
<td rowspan="3"><div align="center"></div></td>
</tr>
<tr>
<td height="23"><div align="right">Unit price </div></td>
<td><input name="unitprice" type="text" id=price /></td>
</tr>
<tr>
<td height="32"><div align="right">Quantity </div></td>
<td><input name="quantity" type="text" id=qty /></td>
</tr>
<tr>
<td height="42" colspan="2"><div align="center"><strong>SALES</strong></div></td>
<td><div align="center"></div>
<div align="center"></div></td>
</tr>
<tr>
<td><div align="right">Gross</div></td>
<td> </td>
<td><div align="center"></div></td>
</tr>
<tr>
<td><div align="right">Type of sale </div></td>
<td><select name="select">
<?php
do {
?>
<option value="<?php echo $row_rsSaletype['type']?>"><?php echo $row_rsSaletype['type']?></option>
<?php
} while ($row_rsSaletype = mysql_fetch_assoc($rsSaletype));
$rows = mysql_num_rows($rsSaletype);
if($rows > 0) {
mysql_data_seek($rsSaletype, 0);
$row_rsSaletype = mysql_fetch_assoc($rsSaletype);
}
?>
</select></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="28" colspan="2"><div align="center"><strong>DEDUCTIONS</strong></div></td>
<td> </td>
</tr>
<tr>
<td height="36"><div align="right">Discount</div></td>
<td height="36"> </td>
<td><div align="center">
<input type="submit" name="Submit" value="ADD NEW" />
</div></td>
</tr>
<tr>
<td height="36"><div align="right">V.A.T</div></td>
<td height="36"> </td>
<td> </td>
</tr>
<tr>
<td height="36"><div align="right">Net</div></td>
<td height="36"> </td>
<td rowspan="2"><div align="center">
<input type="reset" name="Submit5" value="CANCEL" />
</div></td>
</tr>
<tr>
<td height="30" colspan="2"><div align="center">
<label><strong>CALCULATE</strong></label>
</div></td>
</tr>
</table>
</form>
<p> </p>
<p> </p>
</body>
</html>
<?php
mysql_free_result($rsSaletype);
mysql_free_result($rsCustomercategory);
?>
This is manuf.php for adding new stock
<?php require_once('../Connections/bidco.php'); ?>
<?php
if (isset ($_POST ['Submit']))
{
$da=date("Y-m-d");
$itemname=$_POST['itemname'];
$itemcode=$_POST['itemcode'];
$itemtype=$_POST['itemtype'];
$unitprice=$_POST['unitprice'];
$quantity=$_POST['quantity'];
$idate=date("Y-m-d");
mysql_query("INSERT INTO manuf (itemname, itemcode, itemtype, price, qtyleft, Date) VALUES ('$itemname', '$itemcode', '$itemtype', '$unitprice', '$quantity', '$idate')");
header("location:manuf.php");
}
?>
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<p> </p>
<table width="711" height="27" border="0" align="center">
<tr>
<td width="216">Inventory</td>
<td width="152">Sold Goods </td>
<td width="148">Client Details </td>
<td width="167">User Accounts </td>
<td width="167">Home </td>
</tr>
</table>
<p> </p>
<form id="form1" name="form1" method="POST" action="">
<table width="743" height="282" border="1" align="center">
<tr>
<td colspan="3"><div align="center"><strong>ADD NEW PRODUCT </strong></div></td>
</tr>
<tr>
<td colspan="2">Username </td>
<td width="265"><?php date_default_timezone_set('Africa/Nairobi'); echo "Time " . date("h:i:sa");
?></td>
</tr>
<tr>
<td width="180"><div align="right">Item name </div></td>
<td width="276"><input name="itemname" type="text" id="itemname" /></td>
<td> </td>
</tr>
<tr>
<td><div align="right">Item code </div></td>
<td><input name="itemcode" type="text" id="itemcode" /></td>
<td><div align="center"></div></td>
</tr>
<tr>
<td><div align="right">Type</div></td>
<td><input name="itemtype" type="text" id="itemtype" /></td>
<td><div align="center"></div></td>
</tr>
<tr>
<td><div align="right">Unit price </div></td>
<td><input name="unitprice" type="text" id="unitprice" /></td>
<td><div align="center"></div></td>
</tr>
<tr>
<td><div align="right">Quantity</div></td>
<td><input name="quantity" type="text" id="quantity" /></td>
<td><div align="center">
<input type="submit" name="Submit" value="Add stock" />
</div></td>
</tr>
<tr>
<td><div align="right">Date</div></td>
<td><input name="idate" type="varchar" id="idate" /></td>
<td><div align="center">
<input type="reset" name="Submit5" value="Cancel" />
</div></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<div align="center"></div>
<div align="center"></div>
<p> </p>
</body>
</html>

After inserting to sold table, update the manf table as well:
mysql_query("INSERT INTO sold_goods
(itemname, itemcode, itemtype, unitprice, quantity,
transactiontype, customercategory, Date)
VALUES
('$itemname', '$itemcode', '$itemtype', '$unitprice',
'$quantity', '$ttype', '$ccat', '$idate')");
mysql_query("UPDATE manuf SET qtyleft = qtyleft - $quantity where
itemcode = '$itemcode'" );

Related

Update profile using session PHP MySQL

I'm doing project in eCommerce website using PHP and MySQL. I'm having a problem updating user profile page - when I click update button then I check the database, nothing is changed. These is my update.php.
<?php
session_start();
if(!isset($_SESSION["n"]))
{
header("location:error.php");
}
if(isset($_POST["submit"]))
{
$nm=$_POST["name"];
$lnm=$_POST["lname"];
$ad=$_POST["add"];
$u=$_SESSION["un"];
$id=$_GET["id"];
require_once("vars.php");
$conn=mysqli_connect(host,uname,pass,db) or die(mysqli_connect_error());
$query="update signup set name='$nm', lname='$lnm', address='$ad' where User_ID='$id' ";
$execute=mysqli_query($conn,$query);$r=mysql_affected_rows();
mysqli_close($conn);
if(!$execute)
{
$msg="Information Updated Successfully";
}
header("location:mydetails.php");
}
?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body>
<table width="950" align="center">
<tr>
<td>
<table cellspacing="0" cellpadding="0" width="100%">
<tr align="right">
<td>Welcome
<?php
if(isset($_SESSION["n"]))
{
print $_SESSION["n"];
print " <a href='myprofile.php'>My Profile</a>";
print " <a href='signout.php'>Log Out</a>";
}
else
{
print "Guest ";
print "<a href='signup.php'>Sign up</a> ";
print "<a href='login.php'>Login</a>";
}
?></td>
</tr>
<tr>
<td><img src="pics/new2.JPG" alt="banner" width="950" height="234" /></td>
</tr>
<tr align="center">
<td height="58"><table width="100%">
<tr align="center">
<td width="158" bgcolor="#f9b67b"><font color="#FFFFFF">Home</font></td>
<td width="158" bgcolor="#f9b67b" ><font color="#FFFFFF">About us</font></td>
<td width="158" bgcolor="#f9b67b"><font color="#FFFFFF">Products</font></td>
<td width="158" bgcolor="#f9b67b"><font color="#FFFFFF">Search</font></td>
<td width="158" bgcolor="#f9b67b"><font color="#FFFFFF">Contact us</font></td>
</tr>
<tr align="center">
<td colspan="6" align="left"><!-- InstanceBeginEditable name="EditRegion3" -->
<table width="100%">
<tr>
<td><form id="form1" name="form1" method="post" action="">
<table width="100%">
<tr>
<td><h2><strong>Update My Information</strong></h2></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<tr>
</label></td>
</tr>
<tr>
<td><strong>Name:</strong></td>
<td><label>
<input type="text" name="name" id="name" />
</label></td>
</tr>
<tr>
<td><strong>Last name:</strong></td>
<td><label>
<input type="text" name="lname" id="lname" />
</label></td>
</tr>
<tr>
<td><strong>Address:</strong></td>
<td><label>
<input type="text" name="ad" id="ad" />
</label></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="submit" id="submit" value="Update" />
<input type="reset" name="reset" id="reset" value="Reset" /></td>
</label></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- InstanceEndEditable --></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
<div id="footer" >
<h4 style="text-align:center">©2016 by www.thebeautyskin.com</h4>
</div>
<!-- InstanceEnd --></html>
</div>
update signup set name='$nm', lname='$lname', address='$ad'
Where are variables $nm and $ad defined? I see $name and $address....

insert data to database give error result after re edit

i found the insert to database code on internet, use it for trying and its works. but, after i add on some more column, i got error on inserting data to database. which i'm using this code
error_reporting(E_ALL);
ini_set('display_errors','on');
to determine error location, but its show no error on coding. only goes to error result. could anyone help me looking for my mistake and my code error?
here is my insert2_db.php
<?php
//Start session
session_start();
//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['username']) || (trim($_SESSION['password']) == '')) {
header("location: login.php");
exit();
}
?>
<html>
<head>
<title>EXA_mySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body,td,th {
font-family: Tahoma, Geneva, sans-serif;
}
</style>
</head>
<body>
<script type="text/javascript">function checkinput() {
var id_mesin = document.getElementById('id_mesin').value;
if(!id_mesin.match(/\S/)) {
alert ('Please enter Machine ID');
return false;
} else {
return true;
}
}
</script>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form_insert" method="post" action="insert_ac.php" onSubmit="return checkinput(this)">
<table width="100%" height="398" border="0" cellpadding="3" cellspacing="1">
<tr>
<td colspan="9"><strong>Insert Data Into EXA_mySQL Database </strong></td>
</tr>
<tr>
<td width="106">MACHINE ID</td>
<td width="6">:</td>
<td colspan="3"><input name="id_mesin" type="text" id="id_mesin"></td>
<td colspan="2">BRAND</td>
<td width="9">:</td>
<td width="164"><select name="jenama">
<option selected>Please select :</option>
<option value="SHARP">SHARP</option>
<option value="TOSHIBA">TOSHIBA</option>
<option value="CANON">CANON</option>
<option value="SAMSUNG">SAMSUNG</option>
<option value="MEXTEC">MEXTEC</option>
</select></td>
</tr>
<tr>
<td>MODEL</td>
<td>:</td>
<td colspan="3"><input name="model" type="text" id="model"></td>
<td colspan="2">METER START</td>
<td>:</td>
<td><input name="meter_awal" type="text" id="meter_awal" value="0"></td>
</tr>
<tr>
<td>SERIAL NO</td>
<td>:</td>
<td colspan="3">MACHINE</td>
<td colspan="2">FEEDER</td>
<td> </td>
<td>FINISHER</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="3"><input name="siri_mesin" type="text" id="siri_mesin"></td>
<td colspan="3"><input name="siri_feeder" type="text" id="siri_feeder"></td>
<td><input name="siri_finisher" type="text" id="siri_finisher"></td>
</tr>
<tr>
<td>STOCK IN</td>
<td>:</td>
<td width="58">DATE</td>
<td width="8">:</td>
<td width="220"><input type="text" name="stok_in" id="stok_in"></td>
<td colspan="2">D.O NO </td>
<td>:</td>
<td><input type="text" name="in_do" id="in_do"></td>
</tr>
<tr>
<td>LOCATION</td>
<td>:</td>
<td colspan="3"><select name="lokasi">
<option selected>Please select :</option>
<option value="HQ WAREHOUSE">HQ WAREHOUSE</option>
<option value="CHENDERING WAREHOUSE">CHENDERING WAREHOUSE</option>
</select></td>
<td colspan="2">J.S.O</td>
<td>:</td>
<td><input type="text" name="js_order" id="js_order"></td>
</tr>
<tr>
<td>STOCK OUT</td>
<td>:</td>
<td>DATE</td>
<td>:</td>
<td><input type="text" name="stok_out" id="stok_out"></td>
<td colspan="2">D.O NO </td>
<td>:</td>
<td><input type="text" name="out_do" id="out_do"></td>
</tr>
<tr>
<td>CUSTOMER</td>
<td>:</td>
<td colspan="7"><input name="pelangan" type="text" id="pelangan" size="90"></td>
</tr>
<tr>
<td>ADDRESS</td>
<td>:</td>
<td colspan="7"><textarea name="pelangan_alamat" cols="69" id="pelangan_alamat"></textarea></td>
</tr>
<tr>
<td>CONTACT PERSON</td>
<td>:</td>
<td colspan="4"><input name="pelangan_person" type="text" id="pelangan_person" size="50"></td>
<td width="109">NO TEL/HP</td>
<td>:</td>
<td><input type="text" name="pelangan_no" id="pelangan_no"></td>
</tr>
<tr>
<td>TECHNICIAN INCHARGE</td>
<td>:</td>
<td colspan="4"><input name="tech" type="text" id="tech" size="50"></td>
<td>NO TEL/HP</td>
<td>:</td>
<td><input type="text" name="tech_no" id="tech_no"></td>
</tr>
<tr>
<td>STATUS</td>
<td>:</td>
<td colspan="3"><select name="status">
<option selected>Please select :</option>
<option value="ORDER PURCHASE">ORDER PURCHASE</option>
<option value="RENTAL">RENTAL</option>
<option value="HIRE PURCHASE">HIRE PURCHASE</option>
</select></td>
<td colspan="3"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="3"> </td>
<td colspan="3"><input type="reset" value="Clean" /></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
and my insert_ac.php
<?php
//Start session
session_start();
//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['username']) || (trim($_SESSION['password']) == '')) {
header("location: login.php");
exit();
}
?>
<html>
<head>
<title>EXA_mySQL</title>
<script type="text/javascript">
<!--
function CloseWindow() {
window.close();
window.opener.location.reload();
}
//-->
</script>
</head>
<body>
<?php
error_reporting(E_ALL);
ini_set('display_errors','on');
$con=mysqli_connect("localhost","root","admin","exa");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$id_mesin=$_POST['id_mesin'];
$jenama=$_POST['jenama'];
$model=$_POST['model'];
$siri_mesin=$_POST['siri_mesin'];
$siri_feeder=$_POST['siri_feeder'];
$siri_finisher=$_POST['siri_finisher'];
$meter_awal=$_POST['meter_awal'];
$lokasi=$_POST['lokasi'];
$status=$_POST['status'];
$pelangan=$_POST['pelangan'];
//$rekod=$_POST['rekod'];
$stok_in=$_POST['stok_in'];
$stok_out=$_POST['stok_out'];
$in_do=$_POST['in_do'];
$out_do=$_POST['out_do'];
$pelangan_alamat=$_POST['pelangan_alamat'];
$pelangan_no=$_POST['pelangan_no'];
$pelangan_person=$_POST['pelangan_person'];
$js_order=$_POST['js_order'];
$tech=$_POST['tech'];
$tech_no=$_POST['tech_no'];
//$sql2="SELECT * FROM aset where id_mesin = '".$id_mesin."'";
//$result2=mysqli_query($con, $sql2);
$sql="INSERT INTO aset(id_mesin, jenama, model, siri_mesin, siri_feeder, siri_finisher, meter_awal, lokasi, status, pelangan, stok_in, stok_out, in_do, out_do, pelangan_alamat, pelangan_no, pelangan_person, js_order, tech, tech_no) VALUES('$id_mesin', '$jenama', '$model', '$siri_mesin', $siri_feeder, $siri_finisher, '$meter_awal', '$lokasi', '$status', '$pelangan', '$stok_in', '$stok_out', '$in_do', $out_do, $pelangan_alamat, '$pelangan_no', '$pelangan_person', '$js_order', '$tech', '$tech_no')";
$result=mysqli_query($con, $sql);
if($result){//if ($result2 !== 1){
echo "Successful";
echo "<BR>";
echo "<th><form>";
echo "<input type='button' onClick='CloseWindow()' value='Back to Exa_mySQL'>";
echo "</form></th>}";
}//}
else {
echo "Data error, please check your submit.";
echo "<BR>";
echo "<a href='insert.php'>Back to insert form</a>";
}
mysqli_close($con);
?>
</body>
</html>
i'm also using some dropdown list as input on my form, which initial value = Please select: and it has null value. i cant insert data even i put all information on my insert form, all goes to this error result.
echo "Data error, please check your submit.";

Multiple checkbox to a sentence before insert to mysql

I' edit this question with my full coding
Let me post my full code here.
Page1.php
<div id="container">
<div class="box">
<form name="form" method="post" action="userbooking2.php">
<table width="" style="border: 0px solid black" align="center">
<tr>
<td><h2>Book a Room Step 1 - Booking Information</h2></td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="150px" class="titlestyle">Booked by</td>
<td width="400px"><span style="text-transform: uppercase;"><?php echo $_SESSION['SESS_FNAME']; ?></span></td>
</tr>
<tr>
<td class="titlestyle">Title</td>
<td><span class="hint--right" data-hint="Hint : Organization meeting"><input type="text" name="booking_title" id="booking_title" maxlength="50" size="50" /></span></td>
</tr>
<tr>
<td class="titlestyle">Date</td>
<td>From <input type="text" name="booking_start_date" id="booking_start_date"/> to <input type="text" name="booking_end_date" id="booking_end_date"/></td>
</tr>
<tr>
<td class="titlestyle">Time</td>
<td>From <input name="booking_start_time" id="booking_start_time" value="8:00 AM" /> to <input name="booking_end_time" id="booking_end_time" value="8:30 AM"/></td>
</tr>
<tr>
<td class="titlestyle">Room</td>
<td><select name="room_type" id="room_type">
<option value="none">--Select--</option>
<option value="Meeting Room">Meeting Room</option>
<option value="Lecture Room">Lecture Room</option>
<option value="Computer Lab">Computer Lab</option>
</select>
</td>
</tr>
<tr>
<td class="titlestyle">Participant</td>
<td><span class="hint--right" data-hint="Hint : Insert number of participants"><input type="text" name="room_participant" id="room_participant" maxlength="50" size="3" /></span> Persons</td>
</tr>
<tr>
<td class="titlestyle">Equipment</td>
<td><table>
<tr>
<td><input type="checkbox" name="room_facility[]" value="Audio System" />Audio System</td>
<td><input type="checkbox" name="room_facility[]" value="Projector" />Projector</td>
<td><input type="checkbox" name="room_facility[]" value="Video Conferencing" />Video Conferencing</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="titlestyle">Food & Baverages</td>
<td><table>
<tr>
<td><input type="checkbox" name="room_food[]" value="Breakfast" />Breakfast</td>
<td><input type="checkbox" name="room_food[]" value="Tea Break" />Tea Break</td>
<td><input type="checkbox" name="room_food[]" value="Lunch" />Lunch</td>
</tr>
<tr>
<td><input type="checkbox" name="room_food[]" value="High Tea" />High Tea</td>
<td><input type="checkbox" name="room_food[]" value="Dinner" />Dinner</td>
<td><input type="checkbox" name="room_food[]" value="No" />No, thanks</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="titlestyle">Additional Info</td>
<td><span class="hint--right" data-hint="Hint : ."><textarea name="booking_desc" id="booking_desc" style="max-width:400px;" rows="4" cols="50"></textarea></span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="Submit" value="Next" /></td>
</tr>
</table>
</form>
</div>
Page2.php
<?php
//now, let's register our session variables
session_register('fname');
session_register('booking_title');
session_register('booking_start_date');
session_register('booking_end_date');
session_register('booking_start_time');
session_register('booking_end_time');
session_register('room_participant');
session_register('room_type');
session_register('booking_facility');
session_register('booking_food');
session_register('booking_desc');
//finally, let's store our posted values in the session variables
$_SESSION['fname'] = $_SESSION['SESS_FNAME'];
$_SESSION['booking_title'] = $_POST['booking_title'];
$_SESSION['booking_start_date'] = $_POST['booking_start_date'];
$_SESSION['booking_end_date'] = $_POST['booking_end_date'];
$_SESSION['booking_start_time'] = $_POST['booking_start_time'];
$_SESSION['booking_end_time'] = $_POST['booking_end_time'];
$_SESSION['room_participant'] = $_POST['room_participant'];
$_SESSION['room_type'] = $_POST['room_type'];
$_SESSION['room_facility'] = /* WHAT TO SEND HERE? */
$_SESSION['room_food'] = $_POST['room_food'];
$_SESSION['booking_desc'] = $_POST['booking_desc'];?>
// Other form process here
Page3.php
<div id="container">
<div class="box">
<form name="form" method="post" action="">
<table width="" style="border: 0px solid black" align="center">
<tr>
<td><h2>Book a Room Step 3 - Final</h2></td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="150px" class="titlestyle">Booked by</td>
<td width="400px" ><span style="text-transform: uppercase;"><?php echo $_SESSION['SESS_FNAME']; ?></span></td>
</tr>
<tr>
<td class="titlestyle">Title</td>
<td><?php echo $_SESSION['booking_title']; ?></td>
</tr>
<tr>
<td class="titlestyle">Date</td>
<td>From <?php echo $_SESSION['booking_start_date']; ?> to <?php echo $_SESSION['booking_end_date']; ?></td>
</tr>
<tr>
<td class="titlestyle">Time</td>
<td>From <?php echo $_SESSION['booking_start_time']; ?> to <?php echo $_SESSION['booking_end_time']; ?></td>
</tr>
<tr>
<td class="titlestyle">Room</td>
<td><?php echo $_SESSION['room_name']; ?></td>
</tr>
<tr>
<td class="titlestyle">Participant</td>
<td><?php echo $_SESSION['room_participant']; ?> Persons</td>
</tr>
<tr>
<td class="titlestyle">Equipment</td>
<td><?php echo $_SESSION['room_facility']; ?></td>
</tr>
<tr>
<td class="titlestyle">Food & Baverages</td>
<td><?php echo $_SESSION['room_food']; ?></td>
</tr>
<tr>
<td class="titlestyle">Additional Info</td>
<td><?php echo $_SESSION['booking_desc']; ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
</div>
In page3.php, i want to view this kind of string "I book Value1, Value2" before store it into the database
Use:
$string = implode(', ', isset($_REQUEST['room_facility']) ? $_REQUEST['room_facility'] : array());
echo 'I need ' . $string;
Then just insert into the database as normal

Messed up HTML/CSS design [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I'm just checking other people's works and Im fixing this design and I can't seem to have an idea on how to fix it. I don't want to change anything from the css so is it possible to just arrange it on html?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Clinical Module</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="inc/style.css" type="text/css">
</head>
<body>
<form action='' method='POST'><center>
<input type="text" placeholder="Patient Number" name="search" > <input type="submit" Value="Check" name='submit'> <br>
<?php
mysql_connect("localhost","root","");
mysql_select_db("invoices");
$search = 0;
$search=$_POST['search'];
if (isset($_POST['submit'])){
$query = "select * from `patient` where `clientid` = $search ";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){ ?>
First name:<br>
</td>
<td valign="top" align="left">
<input type="text" size="20" name="first_name" value="<?php echo $row["first_name"]?>" ></td>
<td valign="top" width="10%" rowspan="13">
</td>
</tr>
<tr>
<td valign="top" align="right">
Middle name:</td>
<td valign="top" align="left">
<input type="text" size="20" name="middle_name" value="<?php echo $row["middle_name"]?>" ></td>
</td>
</tr>
<tr>
<td valign="top" align="right">
Last Name:
</td>
<td valign="top" align="left">
<input type="text" name="last_name" size="20" value="<?php echo $row["last_name"]?>"></td>
</tr>
<tr>
<td valign="top" align="right">
Birthdate
</td>
<td valign="top" align="left">
<input type="text" name="Birthdate" size="20" value="<?php echo $row["birthdate"]; ?>"></td>
</tr>
<tr>
<td valign="top" align="right">
Age
</td>
<td valign="top" align="left">
<input readonly type="text" name="age" size="20" value="<?php echo $row["age"]?>" placeholder="YYYY-MM-DD"></td>
</tr>
<tr>
<td valign="top" align="right"> Gender:</td>
<td valign="top" align="left"><select name="gender">
<? if ($row["gender"]==Male) { ?>
<option value="Male" selected>Male</option>
<option value="Female">Female</option>
<? }else if ($row["gender"]==Female) { ?>
<option value="Male" >Male</option>
<option value="Female" selected>Female</option> <?php }?>
</select></tr>
</td><tr>
<td valign="top" align="right"> Civil Status:</td>
<td valign="top" align="left"><select name="civil_status">
<? if ($row["civil_status"]==Single) { ?>
<option value="Single" selected >Single</option>
<option value="Married">Married</option>
<option value="Separatede">Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Married) { ?>
<option value="Single" >Single</option>
<option value="Married" selected>Married</option>
<option value="Separated">Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Separated) { ?>
<option value="Single" >Single</option>
<option value="Married">Married</option>
<option value="Separated" selected>Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Widowed) { ?>
<option value="Single" >Single</option>
<option value="Married">Married</option>
<option value="Separated">Separated</option>
<option value="Widowed" selected>Windowed</option> <?php }?>
</select>
</td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Address:</td>
<td valign="top" align="left">
<input type="text" name="address" value="<?php echo $row["address"]?>" size="31"></td>
</tr>
<tr>
<td valign="top" align="right">
Tel. no.:</td>
<td valign="top" align="left">
<input
type="text" size="20" name="telno" placeholder="###-####" value="<?php echo $row["telno"]?>"></td></tr>
<tr>
<td valign="top" align="right">
Occupation:</td>
<td valign="top" align="left">
<input
type="text" size="20" name="occ" value="<?php echo $row["occ"]?>"></td></tr>
<tr>
<td align="right">
Spouse:</td>
<td >
<input
type="text" size="20" name="spo" value="<?php echo $row["spo"]?>"></td></tr><tr>
<td align="right">
Occupation:</td>
<td >
<input
type="text" size="20" name="occ2" value="<?php echo $row["occ2"]?>"></td></tr>
<tr>
<td align="right" width="20">
Contact Person(in case of emergency):</td>
<td >
<input
type="text" size="20" name="cp" value="<?php echo $row["cp"]?>"></td></tr><tr>
<td align="right">
Tel. no:</td>
<td >
<input
type="text" size="20" name="tel2" value="<?php echo $row["tel2"]?>"></td></tr>
<tr>
<td valign="top" align="right" nowrap>
Reffered By:</td>
<td valign="top" align="left">
<input type="text" name="reff" value="<?php echo $row["reff"]?>" size="31" ></td>
</tr>
<tr>
<td class=topHeadrow1 valign="middle" width="50%" colspan="2">
Past Medical History:</td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Allergy:</td>
<td valign="top" align="left">
<input type="text" name="all" value="<?php echo $row["all"]?>" size="31"></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Previous illness:</td>
<td valign="top" align="left">
<input type="text" name="ill" value="<?php echo $row["ill"]?>" size="31"></td>
</tr>
<tr>
<td class=topHeadrow1 valign="middle" width="50%" colspan="2">
<b><font size="4">
Heredo-Familial Diseases:</font></b></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Maternal:
</td>
<td valign="top" align="left">
<input type="text" name="mat" value="<?php echo $row["mat"]?>" size="20"></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Fraternal:
</td>
<td valign="top" align="left">
<input type="text" name="frat" value="<?php echo $row["frat"]?>" size="20"></td>
</tr>
<? }
}
?>
</center>
</form>
|
I'm not sure if this is what you are referring to, as you've not specified a massive amount of information...
However,
You don't seem to have the actual <table> or </table> tags on this form...
No, opening <tr> tag (as pointed out by Tim Medora Below... Thanks!)...
And also no beginning <td valign="top" align="right"> Before your First name:<br>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Clinical Module</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="inc/style.css" type="text/css">
</head>
<body>
<form action='' method='POST'><center>
<input type="text" placeholder="Patient Number" name="search" > <input type="submit" Value="Check" name='submit'> <br>
<table>
<?php
mysql_connect("localhost","root","");
mysql_select_db("invoices");
$search = 0;
$search=$_POST['search'];
if (isset($_POST['submit'])){
$query = "select * from `patient` where `clientid` = $search ";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){ ?>
<tr>
<td valign="top" align="right">
First name:<br>
</td>
<td valign="top" align="left">
<input type="text" size="20" name="first_name" value="<?php echo $row["first_name"]?>" ></td>
<td valign="top" width="10%" rowspan="13">
</td>
</tr>
<tr>
<td valign="top" align="right">
Middle name:</td>
<td valign="top" align="left">
<input type="text" size="20" name="middle_name" value="<?php echo $row["middle_name"]?>" ></td>
</td>
</tr>
<tr>
<td valign="top" align="right">
Last Name:
</td>
<td valign="top" align="left">
<input type="text" name="last_name" size="20" value="<?php echo $row["last_name"]?>"></td>
</tr>
<tr>
<td valign="top" align="right">
Birthdate
</td>
<td valign="top" align="left">
<input type="text" name="Birthdate" size="20" value="<?php echo $row["birthdate"]; ?>"></td>
</tr>
<tr>
<td valign="top" align="right">
Age
</td>
<td valign="top" align="left">
<input readonly type="text" name="age" size="20" value="<?php echo $row["age"]?>" placeholder="YYYY-MM-DD"></td>
</tr>
<tr>
<td valign="top" align="right"> Gender:</td>
<td valign="top" align="left"><select name="gender">
<? if ($row["gender"]==Male) { ?>
<option value="Male" selected>Male</option>
<option value="Female">Female</option>
<? }else if ($row["gender"]==Female) { ?>
<option value="Male" >Male</option>
<option value="Female" selected>Female</option> <?php }?>
</select></tr>
</td><tr>
<td valign="top" align="right"> Civil Status:</td>
<td valign="top" align="left"><select name="civil_status">
<? if ($row["civil_status"]==Single) { ?>
<option value="Single" selected >Single</option>
<option value="Married">Married</option>
<option value="Separatede">Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Married) { ?>
<option value="Single" >Single</option>
<option value="Married" selected>Married</option>
<option value="Separated">Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Separated) { ?>
<option value="Single" >Single</option>
<option value="Married">Married</option>
<option value="Separated" selected>Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Widowed) { ?>
<option value="Single" >Single</option>
<option value="Married">Married</option>
<option value="Separated">Separated</option>
<option value="Widowed" selected>Windowed</option> <?php }?>
</select>
</td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Address:</td>
<td valign="top" align="left">
<input type="text" name="address" value="<?php echo $row["address"]?>" size="31"></td>
</tr>
<tr>
<td valign="top" align="right">
Tel. no.:</td>
<td valign="top" align="left">
<input
type="text" size="20" name="telno" placeholder="###-####" value="<?php echo $row["telno"]?>"></td></tr>
<tr>
<td valign="top" align="right">
Occupation:</td>
<td valign="top" align="left">
<input
type="text" size="20" name="occ" value="<?php echo $row["occ"]?>"></td></tr>
<tr>
<td align="right">
Spouse:</td>
<td >
<input
type="text" size="20" name="spo" value="<?php echo $row["spo"]?>"></td></tr><tr>
<td align="right">
Occupation:</td>
<td >
<input
type="text" size="20" name="occ2" value="<?php echo $row["occ2"]?>"></td></tr>
<tr>
<td align="right" width="20">
Contact Person(in case of emergency):</td>
<td >
<input
type="text" size="20" name="cp" value="<?php echo $row["cp"]?>"></td></tr><tr>
<td align="right">
Tel. no:</td>
<td >
<input
type="text" size="20" name="tel2" value="<?php echo $row["tel2"]?>"></td></tr>
<tr>
<td valign="top" align="right" nowrap>
Reffered By:</td>
<td valign="top" align="left">
<input type="text" name="reff" value="<?php echo $row["reff"]?>" size="31" ></td>
</tr>
<tr>
<td class=topHeadrow1 valign="middle" width="50%" colspan="2">
Past Medical History:</td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Allergy:</td>
<td valign="top" align="left">
<input type="text" name="all" value="<?php echo $row["all"]?>" size="31"></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Previous illness:</td>
<td valign="top" align="left">
<input type="text" name="ill" value="<?php echo $row["ill"]?>" size="31"></td>
</tr>
<tr>
<td class=topHeadrow1 valign="middle" width="50%" colspan="2">
<b><font size="4">
Heredo-Familial Diseases:</font></b></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Maternal:
</td>
<td valign="top" align="left">
<input type="text" name="mat" value="<?php echo $row["mat"]?>" size="20"></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Fraternal:
</td>
<td valign="top" align="left">
<input type="text" name="frat" value="<?php echo $row["frat"]?>" size="20"></td>
</tr>
<? }
}
?>
</table>
</center>
</form>

Incorporate PHP Into HTML Form

I wonder whether someone may be able to help me please.
I'm trying to put together functionality which allows an administrator to search for user details in a mySQL database using the email address as the search criteria. Once the search has taken place I would like the 'first' and 'surname' fields in my form to be completed with the record retrieved.
I think the search is working as the form refreshes but it doesn't retrieve any visible information.
I just wondered whether it would be at all possbible please that someone could take a look at my code below and let me know where I've gone wrong.
Many thanks
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php
require("phpfile.php");
// Opens a connection to a MySQL server
$connection=mysql_connect ("hostname", $username, $password);
if (!$connection) { die('Not connected : ' . mysql_error());}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
$email = $_POST['email'];
$result = mysql_query("SELECT * FROM userdetails WHERE emailaddress like '%$email%'");
?>
<title>Map!</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/gen_validatorv4.js" type="text/javascript"></script>
</head>
<h1> </h1>
<form name="userpasswordreset" id="userpasswordreset" method="post">
<div class="container">
<p align="justify"> </p>
<div class="title1">
<h2>User Details </h2>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="26%" height="25"><strong>Email Address</strong></td>
<td width="4%"> </td>
<td width="70%"><input name="email" type="email" id="email" size="50" /></td>
</tr>
<tr>
<td height="25"><strong>Confirm Email Address </strong></td>
<td> </td>
<td><input name="conf_email" type="email" id="conf_email" size="50" /></td>
</tr>
<tr>
<td height="25"><label>
<input type="submit" name="Submit" value="Search" />
</label></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>First Name </strong></td>
<td> </td>
<td><input name="fname" type="text" id="fname" size="30" value="<?php echo $row['forename']; ?>" /> </td>
</tr>
<tr>
<td height="25"><strong>Last Name </strong></td>
<td> </td>
<td><input name="lname" type="text" id="lname" size="30" value="<?php echo $row['surname']; ?>" /></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>Password</strong></td>
<td> </td>
<td><input name="pass" type="password" id="pass" size="30" /></td>
</tr>
<tr>
<td height="25"><strong>Confirm Password </strong></td>
<td> </td>
<td><input name="conf_pass" type="password" id="conf_pass" size="30" /></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>Password Hint </strong></td>
<td> </td>
<td><input name="hint" type="text" id="hint" size="30" /></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</form>
<script language="JavaScript" type="text/javascript">
// Code for validating the form
var frmvalidator = new Validator("userpasswordreset");
frmvalidator.addValidation("email","req","Please provide your email address");
frmvalidator.addValidation("email","email","Please enter a valid email address");
frmvalidator.addValidation("conf_email","eqelmnt=email", "The confirmed email address is not the same as the email address");
</script>
</div>
</body>
</html>
UPDATED CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php
require("phpfile.php");
// Opens a connection to a MySQL server
$connection=mysql_connect ("hostname", $username, $password);
if (!$connection) { die('Not connected : ' . mysql_error());}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
$email = mysql_real_escape_string($_POST['email']); // make the value safe for in the query
$result = mysql_query("SELECT * FROM userdetails WHERE emailaddress like '%$email%'");
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
}
// $rows is now a multi dimensional array with values found by the query
?>
<title>Map</title>
<script src="js/gen_validatorv4.js" type="text/javascript"></script>
<h1> </h1>
<form name="userpasswordreset" id="userpasswordreset" method="post">
<p align="justify"> </p>
<div class="title1">
<h2>Your Details </h2>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="26%" height="25"><strong>Email Address </strong></td>
<td width="4%"> </td>
<td width="70%"><input name="email" type="email" id="email" size="50" /></td>
</tr>
<tr>
<td height="25"><strong> Confirm Email Address </strong></td>
<td> </td>
<td><input name="conf_email" type="email" id="conf_email" size="50" /></td>
</tr>
<tr>
<td height="25"><label>
<input type="submit" name="Submit" value="Search" />
</label></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>First Name </strong></td>
<td> </td>
<td><input name="fname" type="text" id="fname" size="30" /></td>
</tr>
<tr>
<td height="25"><strong>Last Name</strong></td>
<td> </td>
<td><input name="lname" type="text" id="lname" size="30" /></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>Password</strong></td>
<td> </td>
<td><input name="pass" type="password" id="pass" size="30" /></td>
</tr>
<tr>
<td height="25"><strong>Confirm Password </strong></td>
<td> </td>
<td><input name="conf_pass" type="password" id="conf_pass" size="30" /></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>Password Hint </strong></td>
<td> </td>
<td><input name="hint" type="text" id="hint" size="30" /></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<script language="JavaScript" type="text/javascript">
// Code for validating the form
// Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
// for details
var frmvalidator = new Validator("userpasswordreset");
frmvalidator.addValidation("email","req","Please provide your email address");
frmvalidator.addValidation("email","email","Please enter a valid email address");
frmvalidator.addValidation("conf_email","eqelmnt=email", "The confirmed email address is not the same as the email address");
</script>
</body>
</html>
Aren't you missing the step where you actually run the mysql_fetch_assoc function against your query? Just assigning the result of mysql_query to the variable $result is not enough!
Add something like this after your call to mysql_query:
if($result)
{
$row = mysql_fetch_assoc($result));
}
Edit: mysql_fetch_assoc PHP documentation
To get all the rows resulted with the query you would need to use a mysql fetch function (there are several).
The preffered method is definitly mysql_fetch_assoc
The relevant part of your code would look something like this:
$email = mysql_real_escape_string($_POST['email']); // make the value safe for in the query
$result = mysql_query("SELECT * FROM userdetails WHERE emailaddress like '%$email%'");
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
}
// $rows is now a multi dimensional array with values found by the query
Just going over your code breifly, I dont think your passing the value of the email to in your sql query correctly.
try using this.
$result = mysql_query("SELECT * FROM userdetails WHERE emailaddress like '%" . $email . "%'");

Categories