...

View Full Version : insert id problem ! Help



shakac
09-26-2011, 07:05 PM
hi
please help me
i want to input data from a teacher form that has two part.
no-1 part is for teacher information here code it will insert to teachers_information table

<div id="wb_" style="position:absolute; background-color:#F0F0F0; left:7px; top:8px; width:355px; height:283px; z-index:21">
<form name="contact" method="post" action="teaform1.php" id="" onsubmit="return Validatecontact(this)">
<div id="wb_Text1" style="margin:0; padding:0; position:absolute; left:11px; top:24px; width:108px; height:16px; text-align:left; z-index:0;">
<font style="font-size:13px" color="#000000" face="Arial">Teacher id:</font></div>
<input type="text" id="Editbox1" style="position:absolute; left:127px; top:20px; width:198px; height:18px; border:1px #C0C0C0 solid; font-family:Arial; font-size:13px; z-index:1" name="tid" value="">
<div id="wb_Text2" style="margin:0;padding:0;position:absolute;left:10px;top:70px;width:108px;height:16px;text-align:left;z-index:2;">
<font style="font-size:13px" color="#000000" face="Arial">Last name:</font></div>
<input type="text" id="Editbox2" style="position:absolute;left:128px;top:70px;width:198px;height:18px;border:1px #C0C0C0 solid;font-family:Arial;font-size:13px;z-index:3" name="lname" value="">
<div id="wb_Text3" style="margin:0;padding:0;position:absolute;left:10px;top:95px;width:108px;height:16px;text-align:left;z-index:4;">
<font style="font-size:13px" color="#000000" face="Arial">Joining date:</font></div>
<input type="text" id="Editbox3" style="position:absolute;left:128px;top:95px;width:198px;height:18px;border:1px #C0C0C0 solid;font-family:Arial;font-size:13px;z-index:5" name="joidat" value="">
<div id="wb_Text4" style="margin:0;padding:0;position:absolute;left:10px;top:120px;width:108px;height:16px;text-align:left;z-index:6;">
<font style="font-size:13px" color="#000000" face="Arial">Designation:</font></div>
<input type="text" id="Editbox4" style="position:absolute;left:128px;top:120px;width:198px;height:18px;border:1px #C0C0C0 solid;font-family:Arial;font-size:13px;z-index:7" name="designa" value="">
<input type="submit" id="Button1" name="submit" value="Send" style="position:absolute; left:141px; top:183px; width:96px; height:25px; font-family:Arial; font-size:13px; z-index:16">
<input type="reset" id="Button2" name="" value="Reset" style="position:absolute; left:142px; top:221px; width:96px; height:25px; font-family:Arial; font-size:13px; z-index:17">
<input type="text" id="Editbox9" style="position:absolute; left:127px; top:45px; width:198px; height:18px; border:1px #C0C0C0 solid; font-family:Arial; font-size:13px; z-index:18" name="fname" value="">
<div id="wb_Text9" style="margin:0; padding:0; position:absolute; left:11px; top:48px; width:108px; height:16px; text-align:left; z-index:19;">
<font style="font-size:13px" color="#000000" face="Arial">First name:</font></div>
</form>
</div>

no-2 part is for salary information that will insert to teachers_salary_information

-here code

<?php
print_r($_SESSION);
include("teasession.php");
session_start();
//$tid1=$_POST['tid'];
?>
<div id="wb_" style="position:absolute;background-color:#F0F0F0;left:7px;top:8px;width:355px;height:395px;z-index:21">
<form name="contact" method="post" action="teaformpro.php" id="" onsubmit="return Validatecontact(this)">
<input type="hidden" name="tid1" value="<?php echo"$_SESSION['tid']";?>">
<div id="wb_Text1" style="margin:0; padding:0; position:absolute; left:11px; top:24px; width:108px; height:16px; text-align:left; z-index:0;">
<font style="font-size:13px" color="#000000" face="Arial">Basic salary:</font></div>
<input type="text" id="Editbox1" style="position:absolute; left:127px; top:20px; width:198px; height:18px; border:1px #C0C0C0 solid; font-family:Arial; font-size:13px; z-index:1" name="bsala" value="">
<div id="wb_Text2" style="margin:0;padding:0;position:absolute;left:10px;top:70px;width:108px;height:16px;text-align:left;z-index:2;">
<font style="font-size:13px" color="#000000" face="Arial">Medical:</font></div>
<input type="text" id="Editbox2" style="position:absolute;left:128px;top:70px;width:198px;height:18px;border:1px #C0C0C0 solid;font-family:Arial;font-size:13px;z-index:3" name="medical" value="">
<div id="wb_Text3" style="margin:0;padding:0;position:absolute;left:10px;top:95px;width:108px;height:16px;text-align:left;z-index:4;">
<font style="font-size:13px" color="#000000" face="Arial">City allowance:</font></div>
<input type="text" id="Editbox3" style="position:absolute;left:128px;top:95px;width:198px;height:18px;border:1px #C0C0C0 solid;font-family:Arial;font-size:13px;z-index:5" name="citall" value="">
<div id="wb_Text4" style="margin:0;padding:0;position:absolute;left:10px;top:120px;width:108px;height:16px;text-align:left;z-index:6;">
<font style="font-size:13px" color="#000000" face="Arial">Convince:</font></div>
<input type="text" id="Editbox4" style="position:absolute;left:128px;top:120px;width:198px;height:18px;border:1px #C0C0C0 solid;font-family:Arial;font-size:13px;z-index:7" name="convin" value="">
<div id="wb_Text5" style="margin:0;padding:0;position:absolute;left:10px;top:145px;width:108px;height:16px;text-align:left;z-index:8;">
<font style="font-size:13px" color="#000000" face="Arial">Other allowance:</font></div>
<input type="text" id="Editbox5" style="position:absolute;left:128px;top:145px;width:198px;height:18px;border:1px #C0C0C0 solid;font-family:Arial;font-size:13px;z-index:9" name="otheral" value="">
<div id="wb_Text6" style="margin:0;padding:0;position:absolute;left:10px;top:170px;width:108px;height:16px;text-align:left;z-index:10;">
<font style="font-size:13px" color="#000000" face="Arial">Increment date:</font></div>
<input type="text" id="Editbox6" style="position:absolute;left:128px;top:170px;width:198px;height:18px;border:1px #C0C0C0 solid;font-family:Arial;font-size:13px;z-index:11" name="incdat" value="">
<div id="wb_Text7" style="margin:0;padding:0;position:absolute;left:10px;top:195px;width:108px;height:16px;text-align:left;z-index:12;">
<font style="font-size:13px" color="#000000" face="Arial">Increment amount:</font></div>
<input type="text" id="Editbox7" style="position:absolute;left:128px;top:195px;width:198px;height:18px;border:1px #C0C0C0 solid;font-family:Arial;font-size:13px;z-index:13" name="incamo" value="">
<div id="wb_Text8" style="margin:0;padding:0;position:absolute;left:10px;top:220px;width:108px;height:16px;text-align:left;z-index:14;">
<font style="font-size:13px" color="#000000" face="Arial">Total salary:</font></div>
<input type="text" id="Editbox8" style="position:absolute;left:128px;top:220px;width:198px;height:18px;border:1px #C0C0C0 solid;font-family:Arial;font-size:13px;z-index:15" name="totasal" value="">
<input type="submit" id="Button1" name="submit" value="Send" style="position:absolute;left:133px;top:271px;width:96px;height:25px;font-family:Arial;font-size:13px;z-index:16">
<input type="reset" id="Button2" name="" value="Reset" style="position:absolute;left:133px;top:301px;width:96px;height:25px;font-family:Arial;font-size:13px;z-index:17">
<input type="text" id="Editbox9" style="position:absolute; left:127px; top:45px; width:198px; height:18px; border:1px #C0C0C0 solid; font-family:Arial; font-size:13px; z-index:18" name="hrent" value="">
<div id="wb_Text9" style="margin:0; padding:0; position:absolute; left:11px; top:48px; width:108px; height:16px; text-align:left; z-index:19;">
<font style="font-size:13px" color="#000000" face="Arial">House rent:</font></div>
</form>
</div>

i used session to get all of data here session


<?php
print_r($_SESSION);
session_start();
//finally, let's store our posted values in the session variables
$_SESSION['tid'] = $_POST['tid'];
$_SESSION['fname'] = $_POST['fname'];
$_SESSION['lname'] = $_POST['lname'];
$_SESSION['joidat'] = $_POST['joidat'];
$_SESSION['designa'] = $_POST['designa'];
?>


here process code


<?php
print_r($_SESSION);
session_start();
$tid1=$_GET['tid1'];
//let's create the query
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("anupom", $con);

$tid=mysql_real_escape_string($_SESSION['tid']);
$fname=mysql_real_escape_string($_SESSION['fname']);
$lname=mysql_real_escape_string($_SESSION['lname']);
$joidat=mysql_real_escape_string($_SESSION['joidat']);
$desig=mysql_real_escape_string($_SESSION['designa']);
//$tid1=mysql_real_escape_string($_POST['tid1']);
$bsala=mysql_real_escape_string( $_POST['bsala']);
$hrent=mysql_real_escape_string($_POST['hrent']);
$medical= mysql_real_escape_string($_POST['medical']);
$citall=mysql_real_escape_string($_POST['citall']);
$convin=mysql_real_escape_string($_POST['convin']);
$otheral=mysql_real_escape_string($_POST['otheral']);
$incdat=mysql_real_escape_string( $_POST['incdat']);
$incamo= mysql_real_escape_string($_POST['incamo']);
$totasal= mysql_real_escape_string($_POST['totasal']);

$sql="INSERT INTO teachers_information (teacher_id,teacher_firstname,teacher_lastname,joining_date,designation
)values('$tid','$fname','$lname','$joidat','$desig')";
//mysql_query($sql,$con);
if(!mysql_query($sql,$con))
{
die('error: ' . mysql_error());
}
echo"created";
//$keyid = mysql_insert_id("$tid");

$sql1="INSERT INTO teachers_salary_information (teacher_id,
basic_salary,
house_rent,
medical,
city_allowance,
convince,other_allouance,increament_date,increament_amount,total_salary) values('$tid1','$bsala','$hrent','$medical','$citall','$convin','$otheral','$incdat','$incamo','$tot asal')";
//mysql_query($sql1,$con);
if(!mysql_query($sql1,$con))
{
die('error: ' . mysql_error());
}
echo"created";



//let's run the query
mysql_close($con)
?>

the problem is all of the data from form1 insert to table1 successfully and form2 data are insert table2 successfully but teacher_id did not inserted to table 2 although i get that id from form1.

i used same id teacher_id both table

please anybody help me

shakac
09-26-2011, 07:30 PM
Oh my Allah
finally i found my fault
i did not set character type in my table
i solved this
after 5 hours fighting um very happy now
thanks all



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum