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....
Related
I have five textboxes on the same webpage for five different MySQL queries. I need this because the text in the textbox is different and depend on the MySQL query that I need to do.
May I use a drop down menu or radio button to select different textbox and so to select different MySQL query to execute?
Here is my code:
<table border="1" bgcolor="#FFFFFF">
<tr>
<td align="left">Query per office</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="drawsiti_query_output.php">
<tr>
<td></td>
<td>
<input type="text" name="ufficio" size="20">
</td>
<td align="right"><input type="submit" name="submit" value="Esegui"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<p></p>
<table border="1" bgcolor="#6e00ff">
<tr>
<td align="left">Query per nome</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="drawsiti_query_output_nomesito.php">
<tr>
<td></td>
<td>
<input type="text" name="nomesito" size="20">
</td>
<td align="right"><input type="submit" name="submit" value="Esegui"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<p></p>
<table border="1" bgcolor="#ff0000">
<tr>
<td align="left">Query per codice 2g</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="drawsiti_query_output_2g.php">
<tr>
<td></td>
<td>
<input type="text" name="codice2g" size="20">
</td>
<td align="right"><input type="submit" name="submit" value="Esegui"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<p></p>
<table border="1" bgcolor="#00c2ff">
<tr>
<td align="left">Query per codice 3g</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="drawsiti_query_output_3g.php">
<tr>
<td></td>
<td>
<input type="text" name="codice3g" size="20">
</td>
<td align="right"><input type="submit" name="submit" value="Esegui"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<p></p>
<table border="1" bgcolor="#06fc00">
<tr>
<td align="left">Query per codice 4g</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="drawsiti_query_output_4g.php">
<tr>
<td></td>
<td>
<input type="text" name="codice4g" size="20">
</td>
<td align="right"><input type="submit" name="submit" value="Esegui"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<p></p>
<table border="1" bgcolor="#f100ff">
<tr>
<td align="left">Query per office -> output cell</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="drawsiti_query_output_cell.php">
<tr>
<td></td>
<td>
<input type="text" name="ufficio" size="20">
</td>
<td align="right"><input type="submit" name="submit" value="Esegui"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
You can change input name or form action by select. (or together)
<select>
<option value="ufficio">ufficio</option>
..
</select>
<input type="text" id="inp" name=""/>
<script>
$('select').change(function(){
$('#inp').attr('name', $(this).val());
});
</script>
I want to update my older entries through PHP interface in MongoDB.
First I get data from the text fields and then store that into variables and then using those variables to update data in Mongodb here is my code please help me i tried all ways but every time disappointment.
<?php
if(isset($_REQUEST['btn']))
{
$a=$_REQUEST['textfield'];
$b=$_REQUEST['textfield2'];
$c=$_REQUEST['textfield3'];
$d=$_REQUEST['textfield4'];
$e=$_REQUEST['textfield5'];
$f=$_REQUEST['textfield6'];
$g=$_REQUEST['textfield7'];
$h=$_REQUEST['textfield8'];
$m = new MongoClient(); // connect to mongodb
$db = $m->app; // select a database named app
$collection = $db->lafaz;
$db->lafaz->update(array("_id"=> new MongoID($a)),$doct, array('multiple' => true));
header('Location:page.php');
}?>
<!doctype html>
<html>
<head>
<style type="text/css">
header a {
font-weight: bold;
font-family: Sarina;
font-size: 45pt;
font-style: oblique;
text-decoration: none;
text-shadow: 2px 2px #33CCFF;
color: #369;
}
</style>
<link href="form.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<title>Edit Word</title>
</head>
<body>
<div>
<header align="center">Tarmeem -e- Haraf </header>
<nav align="center">
</nav>
<div align="right" >
<?php
$m = new MongoClient();
$db = $m->app;
$collection = $db->lafaz;
$id=$_REQUEST['_id'];
$cursor = $collection->find(array("_id"=> new MongoID($id)));
foreach ($cursor as $obj)
{
?>
<form action="#" method="post">
<table width="100%" class="top-table" >
<tr>
<td width="40%" align="right"><p>ID:</p></td>
<td width="3%"> </td>
<td width="57%" align="left">
<input class="tf" type="text" name="textfield" id="textfield" readonly value=" <?php echo $obj["_id"]; ?> " ></td>
</tr>
<tr>
<td align="right"><p>Encoding:</p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="textfield2" id="textfield2" required value=" <?php echo $obj["Encoding"]; ?> " ></td>
</tr>
<tr>
<td align="right"><p>Pos:</p> </td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="textfield3" id="textfield3" required value=" <?php echo $obj["Pos"]; ?> " ></td>
</tr>
<tr>
<td align="right"><p>Roman: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="textfield4" id="textfield4" required value=" <?php echo $obj["Roman"]; ?> " ></td>
</tr>
<tr>
<td align="right"><p>Important: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="textfield5" id="textfield5" required value=" <?php echo $obj["Important"]; ?> " ></td>
</tr>
<tr>
<td align="right"><p>Hindi: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="textfield6" id="textfield6" required value=" <?php echo $obj["Hindi"];; ?> " ></td>
</tr>
<tr>
<td align="right"><p>English: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="textfield7" id="textfield7" required value=" <?php echo $obj["English"]; ?> " ></td>
</tr>
<tr>
<td align="right"><p>Type: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="textfield8" id="textfield8" required value=" <?php echo $obj["Type"]; ?> " ></td>
</tr>
</table>
<input name="btn" id="btn" class="button" type="submit" value="Save"></td>
<?php } ?>
</form>
</div>
</div>
</body>
</html>
Here is a fully working page, commented up so you can follow me. You will need to update your PHP runtime to a newer version by the sounds of it but that should already be done, especially since PHP is always backwards compatible currently.
$m = new \MongoClient();
$db = $m->app;
$collection = $db->lafaz;
// Better to sometimes actually check the right array, especially if someone wants to attack
// you by tricking PHP into combining the REQUEST from the GET
if(isset($_POST['btn'])){
// We take the $_POST piece by piece, do a trim to strip white space
// and then we add it to the doc array ready for use in MongoDB
// Of course this is not good practice for production programs but
// it is somewhere to start
$doc = [];
foreach($_POST as $k => $v){
$doc[$k] = trim($v);
}
// This will detect if we are updating or not, if no a is set then no _id was passed
if(isset($doc['_id'])){
// Some validation to ensure that we have a valid MongoID, consider it free knowledge
try{
$_id = new \MongoId($doc['_id']);
}catch(\Exception $e){
throw new \Exception('The _id inputted was not valid: ' . var_export($doc['_id'], true));
}
// Unset the _id as to not raise an error
unset($doc['_id']);
// Could do an upsert here but, meh, I prefer the logic displayed here
$collection->update(["_id"=> $_id], ['$set' => $doc], ['multiple' => true]);
}else{
$collection->insert($doc);
}
// We redirect to somewhere
header('Location:page.php');
// stop further processing and just send the damn headers
exit();
}
// If there is a _id in the REQUEST array
if(isset($_REQUEST['_id'])){
// Some validation to ensure that we have a valid MongoID, consider it free knowledge
try{
$_id = new \MongoId($_REQUEST['_id']);
}catch(\Exception $e){
throw new \Exception('The _id inputted was not valid: ' . var_export($_REQUEST['_id'], true));
}
// We find the one we just did, btw your code atm means this never happens...
$cursor = $collection->find(["_id"=> new \MongoID($_id)]);
}else{
// We just find all
$cursor = $collection->find();
}
?>
<!doctype html>
<html>
<head>
<style type="text/css">
header a {
font-weight: bold;
font-family: Sarina;
font-size: 45pt;
font-style: oblique;
text-decoration: none;
text-shadow: 2px 2px #33CCFF;
color: #369;
}
</style>
<link href="form.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<title>Edit Word</title>
</head>
<body>
<div>
<header align="center">Tarmeem -e- Haraf </header>
<nav align="center">
</nav>
<div align="right">
<!-- Add a new one form. There are better ways to do this but this is just to get it working -->
<form action="#" method="post">
<table width="100%" class="top-table" >
<tr>
<td align="right"><p>Encoding:</p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Encoding" id="textfield2" required></td>
</tr>
<tr>
<td align="right"><p>Pos:</p> </td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Pos" id="textfield3" required></td>
</tr>
<tr>
<td align="right"><p>Roman: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Roman" id="textfield4" required></td>
</tr>
<tr>
<td align="right"><p>Important: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Important" id="textfield5" required></td>
</tr>
<tr>
<td align="right"><p>Hindi: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Hindi" id="textfield6" required></td>
</tr>
<tr>
<td align="right"><p>English: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="English" id="textfield7" required></td>
</tr>
<tr>
<td align="right"><p>Type: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Type" id="textfield8" required></td>
</tr>
</table>
<input name="btn" id="btn" class="button" type="submit" value="Create">
</form>
<?php foreach ($cursor as $obj){ ?>
<form action="#" method="post">
<table width="100%" class="top-table" >
<tr>
<td width="40%" align="right"><p>ID:</p></td>
<td width="3%"> </td>
<td width="57%" align="left">
<input class="tf" type="text" name="_id" id="textfield" readonly value="<?= $obj["_id"] ?>"/></td>
</tr>
<tr>
<td align="right"><p>Encoding:</p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Encoding" id="textfield2" required value="<?= $obj["Encoding"] ?> "/></td>
</tr>
<tr>
<td align="right"><p>Pos:</p> </td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Pos" id="textfield3" required value="<?= $obj["Pos"] ?>"/></td>
</tr>
<tr>
<td align="right"><p>Roman: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Roman" id="textfield4" required value="<?= $obj["Roman"] ?>"/></td>
</tr>
<tr>
<td align="right"><p>Important: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Important" id="textfield5" required value="<?= $obj["Important"] ?>"/></td>
</tr>
<tr>
<td align="right"><p>Hindi: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Hindi" id="textfield6" required value="<?= $obj["Hindi"] ?>"/></td>
</tr>
<tr>
<td align="right"><p>English: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="English" id="textfield7" required value="<?= $obj["English"] ?>"/></td>
</tr>
<tr>
<td align="right"><p>Type: </p></td>
<td> </td>
<td align="left">
<input class="tf" type="text" name="Type" id="textfield8" required value="<?= $obj["Type"] ?>"/></td>
</tr>
</table>
<input name="btn" id="btn" class="button" type="submit" value="Save">
</form>
<?php } ?>
</div>
</div>
</body>
</html>
<?php
Having issue in my application form download.My issue is.once the form is submitted my java script code is not submitting the form to another page.page name is app_print.php.I have implemented js code in php.once every thing is correct.the app_print.php goes to download section.I have hosted in my webserver. Here is the link. http://lisieuxcbsekovai.com/application.php
Here is my code:
application.php
<form action="" method="post" name="application">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td colspan="3">
<?php
if(isset($_POST['application']))
{
unset($_POST['application']);
if(isset($rep))
{
if($rep=='sus')
{
?>
<div class="sus cl"><img class="pa" src="controller/image/btn/tick_circle.png"/><?php echo $msg;?><a style="margin:0px 0px 0px 0px;" href="javascript:void(0);"><img id="close" src="controller/image/btn/cross_grey_small.png"/></a></div>
<?php
}
else if($rep=='fld')
{
?>
<div class="error cl"><img class="pa" src="controller/image/btn/cross_circle.png"/><?php echo $msg;?><img id="close" src="controller/image/btn/cross_grey_small.png"/></div>
<?php
}
else if($rep=='atn')
{
?>
<div class="atn cl"><img class="pa" src="controller/image/btn/exclamation.png"/><?php echo $msg;?><img id="close" src="controller/image/btn/cross_grey_small.png"/></div>
<?php
}
}
}
?>
</td>
</tr>
<tr>
<th class="lft_col" colspan="3" style="color:#DB0009">APPLICATION FORM</th>
</tr>
<tr>
<td class="red">1.</td>
<th class="lft_col"><label>Name of the child<span class="red">*</span><br/><span style="font-size:11px;">(In Block letter)</span></label></th>
<td><input class="text" type="text" name="name" placeholder="Enter your Name" required value=""/></td>
</tr>
<tr>
<td class="red">2.</td>
<th class="lft_col"><label>Sex</label><span class="red">*</span></th>
<td>
<select class="select_2" name="sex" required>
<option value="">---Select---</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
</td>
</tr>
<tr>
<td class="red">3.</td>
<th class="lft_col"><label>Name of Parents<span class="red">*</span></label></th>
<td>
<table style="text-align:left;" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="red">i.</td>
<th class="lft_col">Father Name</th>
<td><input class="text" type="text" name="father" placeholder="Your Father/Guardian Name" required value=""/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="red">ii.</td>
<th class="lft_col">Mother Name</th>
<td><input class="text" type="text" name="mother" placeholder="Your Mother Name" required value=""/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="red">4.</td>
<th class="lft_col"><label>Address for <br/>communication<span class="red">*</span><label></th>
<td><textarea class="text" rows="10" placeholder="Your Communication Address." required name="address"></textarea></td>
</tr>
<tr>
<td class="red">5.</td>
<th class="lft_col">Contact No<span class="red">*</span></th>
<td><input class="text" type="text" name="mobile" placeholder="Mobile:+91 999999999" required value=""/></td>
</tr>
<tr>
<td class="red">6.</td>
<th class="lft_col"><label>Occupation of <br/>Parents with details<span class="red">*</span></label></th>
<td>
<table style="text-align:left;" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="red">i.</td>
<th class="lft_col"><label>Father Occupation</label></th>
<td><input class="text" type="text" name="father_occ" placeholder="Your Father/Guardian Occupation details" required value=""/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="red">ii.</td>
<th class="lft_col"><label>Mother Occupation</label></th>
<td><input class="text" type="text" name="mother_occ" placeholder="Your Mother Occupation details" required value=""/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="red">7.</td>
<th class="lft_col"><label>Date of Birth<span class="red">*</span><br/><span style="font-size:11px;">(as per Birth certificate)</span></label></th>
<td><input class="text" type="date" name="dob" placeholder="Your Date of Birth" required value=""/></td>
</tr>
<tr>
<td class="red">8.</td>
<th class="lft_col"><label>No of Year & Months that will <br/>be Completed as on June 1st<span class="red">*</span></label></th>
<td><input class="text" type="text" name="age" placeholder="Your Age (YYYY/MM/DD)" required value=""/></td>
</tr>
<tr>
<td class="red">9.</td>
<th class="lft_col"><label>Religion & Caste<span class="red">*</span><br/><span style="font-size:11px;">for Statistical purpose only</span></label></th>
<td><input class="text" type="text" name="religion" placeholder="Your Religion & Caste" required value=""/></td>
</tr>
<tr>
<td colspan="2"> </td>
<td class="lft_col">
<input class="btn" type="submit" name="application" value="Submit"/>
<input class="btn" onClick="javascript:window.location='application.php'" type="button" name="Cancel" value="Cancel"/>
</td>
</tr>
</table>
</form>
application.php
if(isset($_POST['application']))
{
$name=$_POST['name'];
$sex=$_POST['sex'];
$father=$_POST['father'];
$mother=$_POST['mother'];
$address=$_POST['address'];
$mobile=$_POST['mobile'];
$father_occ=$_POST['father_occ'];
$mother_occ=$_POST['mother_occ'];
$dob=$_POST['dob'];
$age=$_POST['age'];
$religion=$_POST['religion'];
date_default_timezone_set('Asia/Kolkata');
$cur_date = date('m/d/Y h:i:s a', time());
if($name!=''&&$sex!=''&&$father!=''&&$mother!=''&&$address!=''&&$mobile!=''&&$father_occ!=''&&$mother_occ!=''&&$dob!=''&&$age!=''&&$religion!='')
{
$con_qry=mysql_query("insert into application (name,sex,father,mother,address,mobile,father_occ,mother_occ,dob,age,religion,cur_date) values('".$name."','".$sex."','".$father."','".$mother."','".$address."','".$mobile."','".$father_occ."','".$mother_occ."','".$dob."','".$age."','".$religion."','".$cur_date."')");
if($con_qry)
{
$rep="sus";
$msg='Your application is downloaded, you can print the application from your download path.';
echo "<script type='text/javascript'>var url='app_print.php?id=$cur_date&c_name=$name';window.open(url)</script>";
}
else
{
$rep="fld";
$msg='Registeration Faild.';
}
}
}
?>
my app_print.php:
if((isset($_GET['id']))&&(isset($_GET['c_name'])))
{
$print=mysql_query("select * from application where name='".$_GET['c_name']."' and cur_date='".$_GET['id']."'");
$p_r=mysql_num_rows($print);
if($p_r>0)
{
$print_val=mysql_fetch_array($print);
$aid=$print_val['aid'];
$name=$print_val['name'];
$sex=$print_val['sex'];
$father=$print_val['father'];
$mother=$print_val['mother'];
$address=$print_val['address'];
$mobile=$print_val['mobile'];
$father_occ=$print_val['father_occ'];
$mother_occ=$print_val['mother_occ'];
$dob=$print_val['dob'];
$age=$print_val['age'];
$religion=$print_val['religion'];
$cur_date =$print_val['cur_date'];
header("Content-Type: application/download");
header("Content-Type: application/msword");
header('content-Disposition: attachment; filename='.$name.' Application'.'.doc');
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>LISIEUX - APPLICATION FORM</title>
</head>
<body>
<form action="" method="post" name="app_print">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td colspan="3" style="text-align:center;"><label><b style="font-size:29px;">Lisieux CMI Public School</b></label><br/><label>(CBSE Syllabus)</label><br/><label>Lisieux Road,Saravanampatti,Viswasapuram,Coimbatore - 641035.</label></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td style="border-top:1px solid #000000;"> </td>
<td style="border-top:1px solid #000000;"> </td>
<td style="border-top:1px solid #000000;"> </td>
</tr>
<tr>
<th colspan="3" style="text-align:center;">REGISTRATION FORM</th>
</tr>
<tr>
<td> </td>
<td> </td>
<td style="text-align:right;"><label>Reg.No. : <?php if(isset($aid)){echo $aid;}?></label></td>
</tr>
<tr>
<td>1.</td>
<th><label>Name of the child<br/><span style="font-size:16px;">(In Block letter)</span></label></th>
<td><label><?php if(isset($name)){echo $name;}?></label></td>
</tr>
<tr>
<td>2.</td>
<th><label>Sex</label></th>
<td><label><?php if(isset($sex)){echo $sex;}?></label></td>
</tr>
<tr>
<td>3.</td>
<th><label>Name of Parents</label></th>
<td>
<table style="text-align:left;" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>i.</td>
<th><label>Father : </label></th>
<td><label><?php if(isset($father)){echo $father;}?></label></td>
</tr>
<tr>
<td>ii.</td>
<th><label>Mother : </label></th>
<td><label><?php if(isset($mother)){echo $mother;}?></label></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>4.</td>
<th><label>Address for <br/>communication</label></th>
<td><label><?php if(isset($address)){echo $address;}?></label></td>
</tr>
<tr>
<td>5.</td>
<th>Contact No</th>
<td><label><?php if(isset($mobile)){echo $mobile;}?></label></td>
</tr>
<tr>
<td>6.</td>
<th><label>Occupation of <br/>Parents with details</label></th>
<td>
<table style="text-align:left;" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>i.</td>
<th><label>Father : </label></th>
<td><label><?php if(isset($father_occ)){echo $father_occ;}?></label></td>
</tr>
<tr>
<td>ii.</td>
<th><label>Mother : </label></th>
<td><label><?php if(isset($mother_occ)){echo $mother_occ;}?></label></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>7.</td>
<th><label>Date of Birth<br/><span style="font-size:16px;">(as per Birth certificate)</span></label></th>
<td><label><?php if(isset($dob)){echo $dob;}?></label></td>
</tr>
<tr>
<td>8.</td>
<th><label>No of Year & Months that will be<br/>Completed as on June 1st</label></th>
<td><label><?php if(isset($age)){echo $age;}?></label></td>
</tr>
<tr>
<td>9.</td>
<th><label>Religion & Caste<br/><span style="font-size:16px;">for Statistical purpose only</span></label></th>
<td><label><?php if(isset($religion)){echo $religion;}?></label></td>
</tr>
<tr>
<td colspan="3">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><label>Date : <?php if(isset($cur_date)){echo $cur_date;}?></label></td>
<td style="text-align:right;">Signature of Parent/Guardian</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
window.open does (surprise) open a new browser window. Are you sure there is no pop-up blocker active in your browser? Otherwise you might miss the popup. You can debug Javascript with the F12 debugging tools in all major browsers. Set a breakpoint to the window.open line and see if the line is called. Some pop-up blockers also log to the console also available via F12
window.open() unfortunately has a way of getting 'blocked' by most browsers as an 'unwanted' pop-up if used during a page load - it is probably advisable to use a different way of calling the window.open() statement. An alternative way to accomplish what you are attempting (and side stepping popup blockers) is to consider changing your statement in app_print.php:
echo "<script type='text/javascript'>var url='app_print.php?id=$cur_date&c_name=$name';window.open(url)</script>";
to something like:
echo "<script type='text/javascript'>window.onload=function () { window.location='/app_print.php?id=$cur_date&c_name=$name' }; </script>";
and thus not using window.open() at all.
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'" );
I am doing a simple set of PHP scripts to edit and return MySQL records from a web site.
Everything works fine but there is a cosmetic that I just cannot seem to correct.
I presume being very rusty I am missing something obvious - I have tried everything I can think of though.
The content of field ADDTEXT can be fairly large and i would like to word wrap it all into the table cell. This script truncates it when a single line length is exceeded.
And yes I know I should be using mysqli_... but I am deaeling with that !
<html>
<head>
<title>Form Edit Data</title>
</head>
<body>
<table border=1>
<tr>
<td align=center>EDIT NEWS ITEM</td>
</tr>
<tr>
<td>
<table style="width:100%">
<tr>
<?
$id=$_GET['id'];
include "D***************.uk\public_html\html\ConnectDB.php";//database connection
$order = "SELECT * FROM st¬¬¬¬¬¬¬ where TYPE = '".$id."'";
$result = mysql_query($order);
$row = mysql_fetch_array($result);
?>
<form method="post" action="edit_data.php">
<input type="hidden" name="id" value="<? echo "$row[TITLE]"?>">
<tr>
<td>Item Title</td>
<td>
<input type="text" name="title"
value="<? echo "$row[TITLE]"?>">
</td>
</tr>
<tr>
<td>Item Text</td>
<td>
<input type="text" name="text"
value="<? echo "$row[ADDTEXT]"?>">
</td>
</tr>
<tr>
<td align="right">
<input type="submit"
name="submit value" value="Edit">
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</body>
Change it to textarea field.
<textarea name="text"><?php echo $row['ADDTEXT'];?></textarea>
Try it
<html>
<head>
<title>Form Edit Data</title>
</head>
<body>
<table border=1>
<tr>
<td align=center>EDIT NEWS ITEM</td>
</tr>
<tr>
<td>
<table style="width:100%">
<tr><td>
<?
$id=$_GET['id'];
include "D***************.uk\public_html\html\ConnectDB.php";//database connection
$order = "SELECT * FROM st¬¬¬¬¬¬¬ where TYPE = '".$id."'";
$result = mysql_query($order);
$row = mysql_fetch_array($result);
?>
<form method="post" action="edit_data.php">
<input type="hidden" name="id" value="<?php echo $row['TITLE']?>">
<tr>
<td>Item Title</td>
<td>
<input type="text" name="title"
value="<?php echo $row['TITLE']?>">
</td>
</tr>
<tr>
<td>Item Text</td>
<td>
<input type="text" name="text"
value="<?php echo $row['ADDTEXT']?>">
</td>
</tr>
<tr>
<td align="right">
<input type="submit"
name="submit value" value="Edit">
</td>
</tr>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>