You are here: Losing Session variables between form processes « All PHP « IT news, forums, messages
Losing Session variables between form processes

Posted by GGG on 01/08/07 06:08

I have a two part form where I fill out some main information, populate
a mysql table, then do a query to gather in the ID# of the table I just
populated in order to pass it on to the underlying data table. Then
I write the underlying entries to another table, trying to pass the id
value from the main table (which is an auto_increment(ed) #. It
passes if I have the query go when I'm writing to the main table, but
if I try to run it separate from the main query, I lose the session
data of the number I'm trying to pass.

the underlying form is getting filled out between calls, before
processing continues.


The main problem comes around where the if(isset($ed)){ ...begins.

-- this is located just below the form portion of the page.

Also, when doing the query, the results seem to just append to each
other, especially if I've done a number ot tests already, and just
don't want to keep entering in information over and over again.

There really isn't a way where I can combine this into one form

any suggestions on how to best proceed or other locations I can go to
get help on this process?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<?@session_register('IDa','wcbn');
while (@$var = each(@$_SESSION)) {printf ("Key <b>%s</b> has the value
of: <b>%s</b><br>", @$var['key'], @$var['value']);}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Detail Employee Breakdown.. Premiere CIS</title>
<link href="css/pcis.css" rel="stylesheet" type="text/css">
<?php
//the update of the initial wc table.

if(isset($s4)) {
include 'Spinner.php';
include '../jconn.php';
$wcbn=ucwords($wcbn);$wccity=ucwords($wccity);

$szhP=sizeOf($hp);
for ($count=0; $count <$szhP; $count++)

{
if ($count==0) {$HP= "$hp[$count]";}
else {$HP = $HP . ",$hp[$count]";}

}


//insert partial record, from the first page
$uwc="INSERT INTO wc (";
$uwc.="wcBN,wcAddy,wcCity,wcZip,wcContN,EM,FEIN,wcph,wccell,wcfx,";
//10

$uwc.="wctypeB,wcFT,wcPT,wcEmpRel,wcOpOutCA,qwc,wcCarrier,wcPolNbr,wcPExpDt,wcYrsCarrier,";//10

$uwc.="wcInIpgm,wciipgm,wcRet2work,wcOSHAvio,wcOSHAxp,wc15ftuo,wc15ftd,wc15ftht,wc15ftxp,";//9
$uwc.="wchirpract,yCovB,mCovB,dCovB,insTyp) ";//5
$uwc.="VALUES(";

$uwc.="'$wcbn','$wcaddr','$wccity','$wczip','$wccn','$wcem','$fein','$wcph','$wcc','$wcfx',";
//10

$uwc.="'$wcwt','$wcft','$wcpt','$wcrel','$wcoCA','$wci','$wcc2','$wcpn','$wcped','$wccy',";//10

$uwc.="'$iipp','$iippp','$wcoC','$oshav','$oshaxp','$15feet','$15ftd','$15fth','$15ftxp',";//9
$uwc.="'$HP','$yWC','$mWC','$dWC','wc')";//5

//extract record of latest based on business name. Will return
idnumber associated with it.

mysql_query($uwc) or die ('workers comp insert did not happen'
..mysql_error());

//get idnumber
mysql_close();

}
?>

<?php

include ('sialids/topMenu.php');
// session_register('IDa');//ida is the ID number assigned above
after query has been written.
// there'll be a query to find out what the number is based on
what the first fields name is.

?>



<table width='100%'>

<tr ><td colspan="6" class="enuf"><div class="wagga"
align="center">Your Employee Details</div></tr>
<tr align='left'>
<th>Status
<th>Employmnt<br>Type
<th>Job Title
<th>Pay Rate Info
<th><a title="weeks worked out of the year"

onClick="window.open('wksWork.htm','WW','location=1,status=1,scrollbars=1,width=400,height=200');">Weeks<br>working</a>
</tr>
<form name="wcEmp" method="post" action="<? $_SERVER['PHP_SELF'];
?>">
<?php
$zn=0;
while($zn<>12) {
$zn++;
echo "<tr align='left'><td>";
echo "<select name='s" . $zn . "'>";
echo " <option value='N'>Select One</option>";
echo " <option value='ft'>FT</option><option
name='pt'>PT</option> ";
echo "<td><select name='t" . $zn . "'> ";
echo " <option value='N'>Select One </option>";
echo " <option value='perm'>Permanent</option>";
echo " <option value='temp'>Temp</option>";
echo " <option value='contract'>Leased</option>";
echo " </select>";
echo "<td><input type='text' name='jt" . $zn . "' size='24'
> &nbsp;";
echo "<td>\$<input type='text' name='r" . $zn . "' size='11'
> &nbsp;";
echo "<select name='per" . $zn . "'> ";
echo " <option value='N'>Select One</option>";
echo " <option value='hr'>Hour</option>";
echo " <option value='day'>Day</option>";
echo " <option value='w'>Week</option>";
echo " <option value='m'>Month</option>";
echo " <option value='yr'>Year</option>";
echo " </select>";
echo "<td><input type='text' name='wks" . $zn . "' size='6'
> &nbsp;";

echo "</tr>";

}
echo "<tr class='enuf'><td colspan='6'></tr>";
?>

<tr class="fill">
<th colspan='6' height="30">
<button type="submit" value="S-Mit" name='ed'>Submit
Employee Data</button>&nbsp;
&nbsp;&nbsp;
<button type="reset"
value="r-set">Reset</button></td></tr></table></td>

</tr>
</table>
</form>
<?php
@session_register('IDa','wcbn');
while (@$var = each(@$_SESSION)) {printf ("Key <b>%s</b> has the
value of: <b>%s</b><br>", @$var['key'], @$var['value']);}

if(isset($ed)){


include '../jconn.php';
include 'Spinner.php';
//get idnumber
$wcInq="SELECT wcBN, id from wc where wcBN='$wcbn' LIMIT 5";
//insert this in when ready to go. line 39/43.
$wcI=mysql_query($wcInq) or die ('could not get most recent info on
Employee Entry'.mysql_error());


//fetch valid record (should only be one)
while ($wi=mysql_fetch_array($wcI,MYSQL_BOTH)) {
echo "Current Record is:&nbsp;$wi[1],$wi[0]";
}
$IDa=$wi[1];
echo "ID# is: $IDa";
$idt='wc';

$IDzz=$_POST['IDa'];
$xx=$_REQUEST['IDa'];
$YY=$_SESSION['IDa'];
$ZZ=$_GET['IDa'];

echo"IDZZ=$IDzz<BR>
xx=$xx YY=$YY ZZ=$ZZ";
$i=1;
$peanut="";
while ($peanut<>"N") {

$scal="s$i";$tscal="t$i";$jtscal="jt$i";$rscal="r$i";$perscal="per$i";$wscal="wks$i";

$peanut=$$scal;$tscal=$$tscal;$jtscal=$$jtscal;$rscal=$$rscal;$perscal=$$perscal;$walnut=$$wscal;
echo "values $peanut $jtscal $rscal $perscal $walnut";
//insert the employee info.
$empI="INSERT INTO wcEmployees(";

$empI.="eStatus,eType,ejtitle,epayRt,epayper,ewkswrkd,id,wType)";
$empI.=" VALUES(";

$empI.="'$peanut','$tscal','$jtscal','$rscal','$perscal','$walnut',$IDa,'wc')";
//change out 13, with $IDa, which will be the passover variable.
ECHO "update q to employees tbl: $empI";
if ($i>12) {echo "loop out of control-- stopping page
generation...";exit();}

mysql_query($empI) or die ('wcEmployees wouldn\'t write for
some reason'.mysql_error());
$i++;

}
mysql_close();

include('inc/ems.inc');
$qwc= " Thank you, $wccn, very much for contacting Premiere
Commercial Insurance Services, Inc.
for your company's insurance needs! We appreciate the opportunity
to work with your
company and will have an agent contact you within 24 hours to answer
any questions
you may have regarding obtaining insurance from our agency. \n
You are also welcome to give us a call, should you have questions
ahead of our call, 877.880.2828\n";
$qwc.="Jim Nicolai\n";
$qwc.="Premiere Commercial Insurance Services, Inc";
$MailHead="Content-Type: text/plain; charset=us-ascii\nFrom:
Premiere CIS, Inc <$owner>\nReply-To: <$owner>\nReturn-Path:
<$owner>\nX-Mailer: PHP";
$MailHead.=" \nbcc: Dave N<daven@steric.net>";
$subj="[PREMIERE, CIS]: Recent Workers Comp Quote request";

// mail($qEmail,$subj,$qwc,$MailHead); //actual mailing message.


$uwcd="wcBizname:'$wcbn',\nwcAddress;'$wcaddr',\nwcCity:'$wccity',\nZip:'$wczip',\nCN:'$wccn',\nemail:'$wcem',\nFEIN:'$fein',\nphone:'$wcph',\nCell:'$wcc',\nFax:'$wcfx',";
//10
$uwcd.="\n'$wcwt',\wcFulltime:'$wcft',\nPartTime?:'$wcpt',\nEmploy
Relatives?'$wcrel',\nOutofCA?:'$wcoCA',\nEver purch
wc?'$wci',\nWCCarrier:'$wcc2',\nWCpolicyNumber:'$wcpn',\nWCPolicyExpirDate:'$wcped',\nwcHow
Many Years w/Current Carrier:'$wccy',";//10
$uwcd.="\n have an inj /illness prevention pgm?'$iipp',\nInj n
illness Prevention tailor made?'$iippp',\nearly return-to-work
policy?'$wcoC',\nAny OSHA vio?'$oshav',\n..if so, why? '$oshaxp',\nNE
work performed under, or over/ground, 15'? '$15feet',\n..if so,
depth:'$15ftd',\n..if so, height:'$15fth',\nPlease explain:
'$15ftxp',";//9
$uwcd.="\Adopted Hiring Practices:'$HP',coverage to
begin:'$mWC','$yWC','$dWC','wc')";//5
echo "uwcd";
mail('daven@steric.net',$subj,$uwcd);//test message to dave.


}
?>

<?php
include ('sialids/bottomMenu.php');

?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация