Solved

Code to email form data

Posted on 2011-03-17
14
326 Views
Last Modified: 2012-08-13
The attached code works perfect for me. This code displays data from my mysql database in a browser & allows me to edit it, then re-submit it to the mysql database. Again, all of this works great.

I was wondering if there was a way way for me to add some code to this existing code that would send me an email with the information in the form when the submit button is clicked? Nothing fancy....I'd just like to get an email based off of the location, for example if the location is changed from "Office1" to "Office2", I'd like the email to go to office2@mail.com. If "Office3" is entered, I'd like the form info to go to office3@mail.com.

Is this possible?
<?php # edit_assign.php
$page_title = 'Edit a Record';

$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("psrflow", $con);

//$result = mysql_query("SELECT * FROM psrinfo ");

// Check for a valid user ID, through GET or POST.
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { 
	$id = $_GET['id'];
} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted.
	$id = $_POST['id'];
} else { // No valid ID, kill the script.
	echo '<h1 id="mainhead">Page Error</h1>
	<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
	include ('./includes/footer.html'); 
	exit();
}
// Check if the form has been submitted.

if (isset($_POST['submitted'])) {

	$errors = array(); // Initialize error array.

	if (empty($_POST['pacts'])) {
		$errors[] = 'You forgot to enter a PACTS number. If there is no PACTS # you can enter 0000';
	} else {
		$pt = $_POST['pacts'];
	}
	
	if (empty($_POST['fname'])) {
		$errors[] = 'You forgot to enter the first name.';
	} else {
		$fn = $_POST['fname'];
	}
	
	if (empty($_POST['lname'])) {
		$errors[] = 'You forgot to enter the last name.';
	} else {
		$ln = $_POST['lname'];
	}
	
	if (empty($_POST['status'])) {
		$errors[] = 'You forgot to enter a status.';
	} else {
		$st = $_POST['status'];
	}
	
	if (empty($_POST['assgn_date'])) {
		$errors[] = 'You forgot to enter an assign date.';
	} else {
		$ad = $_POST['assgn_date'];
	}
	
	if (empty($_POST['interv_date'])) {
		$errors[] = 'You forgot to enter an interview date.';
	} else {
		$iv = $_POST['interv_date'];
	}
	
		if (empty($_POST['due_rev'])) {
		$errors[] = 'You forgot to enter a due to reviewer date.';
	} else {
		$rv = $_POST['due_rev'];
	}
	
		if (empty($_POST['due_suspo'])) {
		$errors[] = 'You forgot to enter a due to SUSPO date.';
	} else {
		$sus = $_POST['due_suspo'];
	}
	
		if (empty($_POST['due_clerk'])) {
		$errors[] = 'You forgot to enter a due to clerk date.';
	} else {
		$clk = $_POST['due_clerk'];
	}
	
	
		if (empty($_POST['due_owner'])) {
		$errors[] = 'You forgot to enter a due to owner date.';
	} else {
		$jdg = $_POST['due_owner'];
	}
	
		if (empty($_POST['location'])) {
		$errors[] = 'You forgot to enter a location.';
	} else {
		$loc = $_POST['location'];
	}
	
		if (empty($_POST['employee'])) {
		$errors[] = 'You forgot to enter a employee.';
	} else {
		$off = $_POST['employee'];
	}
	
		if (empty($_POST['sent_date'])) {
		$errors[] = 'You forgot to enter a sent date.';
	} else {
		$sd = $_POST['sent_date'];
	}
		if (empty($_POST['oth_date'])) {
		$errors[] = 'You forgot to enter an other date.';
	} else {
		$oth = $_POST['oth_date'];
	}
	
		if (empty($_POST['due_attny'])) {
		$errors[] = 'You forgot to enter an att date.';
	} else {
		$atn = $_POST['due_attny'];
	}
	
	if (empty($errors)) { // If everything's OK.

		$query = "UPDATE psrinfo SET pacts='$pt', fname='$fn', lname='$ln', status='$st', location='$loc', employee='$off', sent_date='$sd', oth_date='$oth', assgn_date='$ad', interv_date='$iv', due_rev='$rv', due_suspo='$sus', due_clerk='$clk', due_attny='$atn', due_owner='$jdg'  WHERE fid=$id";
		$result = @mysql_query ($query); // Run the query.

$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
if ((substr($url, -1) == '/') OR (substr($url, -1) == '//')) {
$url = substr ($url, 0, -1);
}
$url ='/flow/index.html'; 

header("Location: $url");
exit();
		
	} else { // Report the errors.
	
		echo '<h1 id="mainhead">Error!</h1>
		<p class="error">The following error(s) occurred:<br />';
		foreach ($errors as $msg) { // Print each error.
			echo " - $msg<br />\n";
		}
		echo '</p><p>Please try again.</p><p><br /></p>';
		
	} // End of if (empty($errors)) IF.

} // End of submit conditional.

// Retrieve the user's information.
$query = "SELECT pacts, fname, lname, status, employee, location, assgn_date, interv_date, sent_date, oth_date, due_rev, due_suspo, due_clerk, due_attny, due_owner FROM psrinfo WHERE fid = " . $_REQUEST['id'];
$result = @mysql_query ($query); // Run the query.

if (mysql_num_rows($result) == 1) { 

	$row = mysql_fetch_array ($result, MYSQL_NUM);
	
?>	

<script type="text/javascript">
var valid;

function d2(v) { return (v<10)?("0"+v):v; }

function dcheck(form) {
var a = form.assgn_date.value;
var s = form.sent_date.value;
var i = form.interv_date.value;
var dr = form.due_rev.value
var su = form.due_suspo
var clk = form.due_clerk
var att = form.due_attny
var jdg = form.due_owner
var assn  = new Date(a);
var sent = new Date(s);
var intv = new Date(i);
var due_rev = new Date(dr);
var due_suspo = new Date(su);
var due_clerk = new Date(clk);
var due_attny = new Date(att);
var due_owner = new Date(jdg);


if (isNaN(intv)) {
intv = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()+0);
}
if (isNaN(assn)) {
assn = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()+0);
}
if (isNaN(due_rev)) {
due_rev = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-42);
}
if (isNaN(due_suspo)) {
due_suspo = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-40);
}
if (isNaN(due_clerk)) {
due_clerk = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-38);
}
if (isNaN(due_attny)) {
due_attny = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-36);
}
if (isNaN(due_owner)) {
due_owner = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-7);
}


switch(due_rev.getDay()){
  case 0: due_rev.setDate(due_rev.getDate() - 1); // take one for Sunday
  case 6: due_rev.setDate(due_rev.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_suspo.getDay()){
  case 0: due_suspo.setDate(due_suspo.getDate() - 1); // take one for Sunday
  case 6: due_suspo.setDate(due_suspo.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_clerk.getDay()){
  case 0: due_clerk.setDate(due_clerk.getDate() - 1); // take one for Sunday
  case 6: due_clerk.setDate(due_clerk.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_attny.getDay()){
  case 0: due_attny.setDate(due_attny.getDate() - 1); // take one for Sunday
  case 6: due_attny.setDate(due_attny.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_owner.getDay()){
  case 0: due_owner.setDate(due_owner.getDate() - 1); // take one for Sunday
  case 6: due_owner.setDate(due_owner.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_rev.getDay()){
  case 0: due_rev.setDate(due_rev.getDate() - 1); // take one for Sunday
  case 6: due_rev.setDate(due_rev.getDate() - 1); // take two for Sunday or one for Saturday
}

//form.assgn_date.value = (assn.getFullYear()+0) + "-" + d2(assn.getMonth()+1) + "-" + d2(assn.getDate());
//form.interv_date.value = (intv.getFullYear()+0) + "-" + d2(intv.getMonth()+1) + "-" + d2(intv.getDate());
form.sent_date.value = (sent.getFullYear()+0) + "-" + d2(sent.getMonth()+1) + "-" + d2(sent.getDate());
form.due_rev.value = (due_rev.getFullYear()+0) + "-" + d2(due_rev.getMonth()+1) + "-" + d2(due_rev.getDate());
form.due_suspo.value = (due_suspo.getFullYear()+0) + "-" + d2(due_suspo.getMonth()+1) + "-" + d2(due_suspo.getDate());
form.due_clerk.value = (due_clerk.getFullYear()+0) + "-" + d2(due_clerk.getMonth()+1) + "-" + d2(due_clerk.getDate());
form.due_attny.value = (due_attny.getFullYear()+0) + "-" + d2(due_attny.getMonth()+1) + "-" + d2(due_attny.getDate());
form.due_owner.value = (due_owner.getFullYear()+0) + "-" + d2(due_owner.getMonth()+1) + "-" + d2(due_owner.getDate());
return true;
}

</script>
<?php

echo '<form action="edit_assign.php" method="post">
<fieldset><legend><h1> You are editing a record!</h1></legend>

<b>PACTS No:</b> <br><input type="text" name="pacts" size="15" maxlength="30" value="'.$row[0].'" /><br>
<b>First Name:</b> <br><input type="text" name="fname" size="15" maxlength="30" value="'.$row[1].'" /><br />
<b>Last Name:</b> <br><input type="text" name="lname" size="15" maxlength="30" value="'.$row[2].'" /><br />
<b>Status: </b><br><input type="text" name="status" size="15" maxlength="30" value="'.$row[3].'" /> <br>
<b>Location: </b><br><input type="text" name="location" size="15" maxlength="30" value="'.$row[5].'" /><br>
<b>Employee: </b><br><input type="text" name="employee" size="15" maxlength="30" value="'.$row[4].'" /> <br>

<b>Sentence Date: MM/DD/YYYY </b><br><input type="text" name="sent_date" size="15" maxlength="30" value="'.$row[8].'" /> <br>

<p><input type="button" value="Calculate" onclick="return dcheck(this.form);">	

<b>-----------------------------------------------------------</b> <br /><br>

<b>Other Date:</b><br><input type="text" name="oth_date" size="15" maxlength="30" value="'.$row[9].'" /> <br>
<b>Assign Date:  </b><br><input type="text" name="assgn_date" size="15" maxlength="30" value="'.$row[6].'" /> <br>
<b>Interview Date:  </b><br><input type="text" name="interv_date" size="15" maxlength="30" value="'.$row[7].'" /> <br>
<b>Due to Reviewer:</b><br><input type="text" name="due_rev" size="15" maxlength="30" value="'.$row[10].'" /> <br>
<b>Due to SUSPO:</b><br><input type="text" name="due_suspo" size="15" maxlength="30" value="'.$row[11].'" /> <br>
<b>Due to Clerk:</b><br><input type="text" name="due_clerk" size="15" maxlength="30" value="'.$row[12].'" /> <br>
<b>Due to Att:</b><br><input type="text" name="due_attny" size="15" maxlength="30" value="'.$row[13].'" /> <br>
<b>Due to owner:</b><br><input type="text" name="due_owner" size="15" maxlength="30" value="'.$row[14].'" /> <br>
<br>
</fieldset>

<div align="left"><input type="submit" name="submit" value="Submit" /></div>

<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
</form>';

} else { 
	echo '<h1 id="mainhead">Page Error</h1>
	<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
}

mysql_close(); 

?>

Open in new window

0
Comment
Question by:wantabe2
  • 7
  • 7
14 Comments
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35156446
If you put this below your update statement an email will be send according to the location,
this is a little example to get you in the right direction.

		
		// Send mail according to location
		switch ($loc) {
			case 'office1':
				$sEmailAddress = 'office1@mail.com';
			break;
			
			case 'office2':
				$sEmailAddress = 'office2@mail.com';
			break;
		}
		mail($sEmailAddress, $sSubject, $sMessage, $sHeaders);

Open in new window

0
 
LVL 15

Author Comment

by:wantabe2
ID: 35156515
Thanks,
I put that after line 125 & the mysql database was updated but no email...any ideas? Thanks again for any help provided!
0
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35156661
I would recommend to do a search on that problem or start a new question here because that can be alot of things (mostly server dependant):
http://www.google.nl/search?hl=nl&biw=1920&bih=993&q=php+mail+not+sending&aq=f&aqi=g1&aql=&oq=
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 15

Author Comment

by:wantabe2
ID: 35156783
Okay, I checked my php.ini file by comparing it to another php.ini file on another server & it looks fine. I can ping the smtp server from this box so I'm sure there is no problem with the .php.ini file... is the code below all I need to add to the code in order for it to work? If possible, could I see a little bit more in an example? Thanks
// Send mail according to location
		switch ($loc) {
			case 'office1':
				$sEmailAddress = 'office1@mail.com';
			break;
			
			case 'office2':
				$sEmailAddress = 'office2@mail.com';
			break;
		}
		mail($sEmailAddress, $sSubject, $sMessage, $sHeaders);

Open in new window

0
 
LVL 15

Author Comment

by:wantabe2
ID: 35156866
I added my full code with the code provided in this post so someone can help me figure where I'm going wrong with this. Thanks
<?php # edit_assign.php
$page_title = 'Edit a Record';

$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("psrflow", $con);

//$result = mysql_query("SELECT * FROM psrinfo ");

// Check for a valid user ID, through GET or POST.
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { 
	$id = $_GET['id'];
} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted.
	$id = $_POST['id'];
} else { // No valid ID, kill the script.
	echo '<h1 id="mainhead">Page Error</h1>
	<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
	include ('./includes/footer.html'); 
	exit();
}
// Check if the form has been submitted.

if (isset($_POST['submitted'])) {

	$errors = array(); // Initialize error array.

	if (empty($_POST['pacts'])) {
		$errors[] = 'You forgot to enter a PACTS number. If there is no PACTS # you can enter 0000';
	} else {
		$pt = $_POST['pacts'];
	}
	
	if (empty($_POST['fname'])) {
		$errors[] = 'You forgot to enter the first name.';
	} else {
		$fn = $_POST['fname'];
	}
	
	if (empty($_POST['lname'])) {
		$errors[] = 'You forgot to enter the last name.';
	} else {
		$ln = $_POST['lname'];
	}
	
	if (empty($_POST['status'])) {
		$errors[] = 'You forgot to enter a status.';
	} else {
		$st = $_POST['status'];
	}
	
	if (empty($_POST['assgn_date'])) {
		$errors[] = 'You forgot to enter an assign date.';
	} else {
		$ad = $_POST['assgn_date'];
	}
	
	if (empty($_POST['interv_date'])) {
		$errors[] = 'You forgot to enter an interview date.';
	} else {
		$iv = $_POST['interv_date'];
	}
	
		if (empty($_POST['due_rev'])) {
		$errors[] = 'You forgot to enter a due to reviewer date.';
	} else {
		$rv = $_POST['due_rev'];
	}
	
		if (empty($_POST['due_suspo'])) {
		$errors[] = 'You forgot to enter a due to SUSPO date.';
	} else {
		$sus = $_POST['due_suspo'];
	}
	
		if (empty($_POST['due_clerk'])) {
		$errors[] = 'You forgot to enter a due to clerk date.';
	} else {
		$clk = $_POST['due_clerk'];
	}
	
	
		if (empty($_POST['due_owner'])) {
		$errors[] = 'You forgot to enter a due to owner date.';
	} else {
		$jdg = $_POST['due_owner'];
	}
	
		if (empty($_POST['location'])) {
		$errors[] = 'You forgot to enter a location.';
	} else {
		$loc = $_POST['location'];
	}
	
		if (empty($_POST['employee'])) {
		$errors[] = 'You forgot to enter a employee.';
	} else {
		$off = $_POST['employee'];
	}
	
		if (empty($_POST['sent_date'])) {
		$errors[] = 'You forgot to enter a sent date.';
	} else {
		$sd = $_POST['sent_date'];
	}
		if (empty($_POST['oth_date'])) {
		$errors[] = 'You forgot to enter an other date.';
	} else {
		$oth = $_POST['oth_date'];
	}
	
		if (empty($_POST['due_attny'])) {
		$errors[] = 'You forgot to enter an att date.';
	} else {
		$atn = $_POST['due_attny'];
	}
	
	if (empty($errors)) { // If everything's OK.

		$query = "UPDATE psrinfo SET pacts='$pt', fname='$fn', lname='$ln', status='$st', location='$loc', employee='$off', sent_date='$sd', oth_date='$oth', assgn_date='$ad', interv_date='$iv', due_rev='$rv', due_suspo='$sus', due_clerk='$clk', due_attny='$atn', due_owner='$jdg'  WHERE fid=$id";
		$result = @mysql_query ($query); // Run the query.


// Send mail according to location
		switch ($loc) {
			case 'office1':
				$sEmailAddress = 'office1@mail.com';
			break;
			
			case 'office2':
				$sEmailAddress = 'office2@mail.com';
			break;
		}
		mail($sEmailAddress, $sSubject, $sMessage, $sHeaders);



$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
if ((substr($url, -1) == '/') OR (substr($url, -1) == '//')) {
$url = substr ($url, 0, -1);
}
$url ='/flow/index.html'; 

header("Location: $url");
exit();
		
	} else { // Report the errors.
	
		echo '<h1 id="mainhead">Error!</h1>
		<p class="error">The following error(s) occurred:<br />';
		foreach ($errors as $msg) { // Print each error.
			echo " - $msg<br />\n";
		}
		echo '</p><p>Please try again.</p><p><br /></p>';
		
	} // End of if (empty($errors)) IF.

} // End of submit conditional.

// Retrieve the user's information.
$query = "SELECT pacts, fname, lname, status, employee, location, assgn_date, interv_date, sent_date, oth_date, due_rev, due_suspo, due_clerk, due_attny, due_owner FROM psrinfo WHERE fid = " . $_REQUEST['id'];
$result = @mysql_query ($query); // Run the query.

if (mysql_num_rows($result) == 1) { 

	$row = mysql_fetch_array ($result, MYSQL_NUM);
	
?>	

<script type="text/javascript">
var valid;

function d2(v) { return (v<10)?("0"+v):v; }

function dcheck(form) {
var a = form.assgn_date.value;
var s = form.sent_date.value;
var i = form.interv_date.value;
var dr = form.due_rev.value
var su = form.due_suspo
var clk = form.due_clerk
var att = form.due_attny
var jdg = form.due_owner
var assn  = new Date(a);
var sent = new Date(s);
var intv = new Date(i);
var due_rev = new Date(dr);
var due_suspo = new Date(su);
var due_clerk = new Date(clk);
var due_attny = new Date(att);
var due_owner = new Date(jdg);


if (isNaN(intv)) {
intv = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()+0);
}
if (isNaN(assn)) {
assn = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()+0);
}
if (isNaN(due_rev)) {
due_rev = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-42);
}
if (isNaN(due_suspo)) {
due_suspo = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-40);
}
if (isNaN(due_clerk)) {
due_clerk = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-38);
}
if (isNaN(due_attny)) {
due_attny = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-36);
}
if (isNaN(due_owner)) {
due_owner = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-7);
}


switch(due_rev.getDay()){
  case 0: due_rev.setDate(due_rev.getDate() - 1); // take one for Sunday
  case 6: due_rev.setDate(due_rev.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_suspo.getDay()){
  case 0: due_suspo.setDate(due_suspo.getDate() - 1); // take one for Sunday
  case 6: due_suspo.setDate(due_suspo.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_clerk.getDay()){
  case 0: due_clerk.setDate(due_clerk.getDate() - 1); // take one for Sunday
  case 6: due_clerk.setDate(due_clerk.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_attny.getDay()){
  case 0: due_attny.setDate(due_attny.getDate() - 1); // take one for Sunday
  case 6: due_attny.setDate(due_attny.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_owner.getDay()){
  case 0: due_owner.setDate(due_owner.getDate() - 1); // take one for Sunday
  case 6: due_owner.setDate(due_owner.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_rev.getDay()){
  case 0: due_rev.setDate(due_rev.getDate() - 1); // take one for Sunday
  case 6: due_rev.setDate(due_rev.getDate() - 1); // take two for Sunday or one for Saturday
}

//form.assgn_date.value = (assn.getFullYear()+0) + "-" + d2(assn.getMonth()+1) + "-" + d2(assn.getDate());
//form.interv_date.value = (intv.getFullYear()+0) + "-" + d2(intv.getMonth()+1) + "-" + d2(intv.getDate());
form.sent_date.value = (sent.getFullYear()+0) + "-" + d2(sent.getMonth()+1) + "-" + d2(sent.getDate());
form.due_rev.value = (due_rev.getFullYear()+0) + "-" + d2(due_rev.getMonth()+1) + "-" + d2(due_rev.getDate());
form.due_suspo.value = (due_suspo.getFullYear()+0) + "-" + d2(due_suspo.getMonth()+1) + "-" + d2(due_suspo.getDate());
form.due_clerk.value = (due_clerk.getFullYear()+0) + "-" + d2(due_clerk.getMonth()+1) + "-" + d2(due_clerk.getDate());
form.due_attny.value = (due_attny.getFullYear()+0) + "-" + d2(due_attny.getMonth()+1) + "-" + d2(due_attny.getDate());
form.due_owner.value = (due_owner.getFullYear()+0) + "-" + d2(due_owner.getMonth()+1) + "-" + d2(due_owner.getDate());
return true;
}

</script>
<?php

echo '<form action="edit_assign.php" method="post">
<fieldset><legend><h1> You are editing a record!</h1></legend>

<b>PACTS No:</b> <br><input type="text" name="pacts" size="15" maxlength="30" value="'.$row[0].'" /><br>
<b>First Name:</b> <br><input type="text" name="fname" size="15" maxlength="30" value="'.$row[1].'" /><br />
<b>Last Name:</b> <br><input type="text" name="lname" size="15" maxlength="30" value="'.$row[2].'" /><br />
<b>Status: </b><br><input type="text" name="status" size="15" maxlength="30" value="'.$row[3].'" /> <br>
<b>Location: </b><br><input type="text" name="location" size="15" maxlength="30" value="'.$row[5].'" /><br>
<b>Employee: </b><br><input type="text" name="employee" size="15" maxlength="30" value="'.$row[4].'" /> <br>

<b>Sentence Date: MM/DD/YYYY </b><br><input type="text" name="sent_date" size="15" maxlength="30" value="'.$row[8].'" /> <br>

<p><input type="button" value="Calculate" onclick="return dcheck(this.form);">	

<b>-----------------------------------------------------------</b> <br /><br>

<b>Other Date:</b><br><input type="text" name="oth_date" size="15" maxlength="30" value="'.$row[9].'" /> <br>
<b>Assign Date:  </b><br><input type="text" name="assgn_date" size="15" maxlength="30" value="'.$row[6].'" /> <br>
<b>Interview Date:  </b><br><input type="text" name="interv_date" size="15" maxlength="30" value="'.$row[7].'" /> <br>
<b>Due to Reviewer:</b><br><input type="text" name="due_rev" size="15" maxlength="30" value="'.$row[10].'" /> <br>
<b>Due to SUSPO:</b><br><input type="text" name="due_suspo" size="15" maxlength="30" value="'.$row[11].'" /> <br>
<b>Due to Clerk:</b><br><input type="text" name="due_clerk" size="15" maxlength="30" value="'.$row[12].'" /> <br>
<b>Due to Att:</b><br><input type="text" name="due_attny" size="15" maxlength="30" value="'.$row[13].'" /> <br>
<b>Due to owner:</b><br><input type="text" name="due_owner" size="15" maxlength="30" value="'.$row[14].'" /> <br>
<br>
</fieldset>

<div align="left"><input type="submit" name="submit" value="Submit" /></div>

<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
</form>';

} else { 
	echo '<h1 id="mainhead">Page Error</h1>
	<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
}

mysql_close(); 

?>

Open in new window

0
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35156961
Ah, you didn't change any of the parameters,
the parameters i put in where suggestions in the hope you would fill them in:

$sSubject = 'Subject';
$sMessage = 'Message';
$sHeaders = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
mail($sEmailAddress, $sSubject, $sMessage, $sHeaders);

Open in new window


I hope this will work for you.
0
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35156992
Some sitenote,
you should also change this to the right information,
only when $loc is office1 or office2 an emailaddress will be created (you can add additional cases).
And be sure to change the emailaddress to one you own.

		switch ($loc) {
			case 'office1':
				$sEmailAddress = 'office1@mail.com';
			break;
			
			case 'office2':
				$sEmailAddress = 'office2@mail.com';
			break;
		}

Open in new window

0
 
LVL 15

Author Comment

by:wantabe2
ID: 35157124
Thanks, I attached my full code again with the updated code you suggested. It still is not working & I'm getting no errors...am I putting it in the correct location in the code? My new code is located between lines 135 - 162. Thanks
<?php # edit_assign.php
$page_title = 'Edit a Record';

$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("psrflow", $con);

//$result = mysql_query("SELECT * FROM psrinfo ");

// Check for a valid user ID, through GET or POST.
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { 
	$id = $_GET['id'];
} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted.
	$id = $_POST['id'];
} else { // No valid ID, kill the script.
	echo '<h1 id="mainhead">Page Error</h1>
	<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
	include ('./includes/footer.html'); 
	exit();
}
// Check if the form has been submitted.

if (isset($_POST['submitted'])) {

	$errors = array(); // Initialize error array.

	if (empty($_POST['pacts'])) {
		$errors[] = 'You forgot to enter a PACTS number. If there is no PACTS # you can enter 0000';
	} else {
		$pt = $_POST['pacts'];
	}
	
	if (empty($_POST['fname'])) {
		$errors[] = 'You forgot to enter the first name.';
	} else {
		$fn = $_POST['fname'];
	}
	
	if (empty($_POST['lname'])) {
		$errors[] = 'You forgot to enter the last name.';
	} else {
		$ln = $_POST['lname'];
	}
	
	if (empty($_POST['status'])) {
		$errors[] = 'You forgot to enter a status.';
	} else {
		$st = $_POST['status'];
	}
	
	if (empty($_POST['assgn_date'])) {
		$errors[] = 'You forgot to enter an assign date.';
	} else {
		$ad = $_POST['assgn_date'];
	}
	
	if (empty($_POST['interv_date'])) {
		$errors[] = 'You forgot to enter an interview date.';
	} else {
		$iv = $_POST['interv_date'];
	}
	
		if (empty($_POST['due_rev'])) {
		$errors[] = 'You forgot to enter a due to reviewer date.';
	} else {
		$rv = $_POST['due_rev'];
	}
	
		if (empty($_POST['due_suspo'])) {
		$errors[] = 'You forgot to enter a due to SUSPO date.';
	} else {
		$sus = $_POST['due_suspo'];
	}
	
		if (empty($_POST['due_clerk'])) {
		$errors[] = 'You forgot to enter a due to clerk date.';
	} else {
		$clk = $_POST['due_clerk'];
	}
	
	
		if (empty($_POST['due_owner'])) {
		$errors[] = 'You forgot to enter a due to owner date.';
	} else {
		$jdg = $_POST['due_owner'];
	}
	
		if (empty($_POST['location'])) {
		$errors[] = 'You forgot to enter a location.';
	} else {
		$loc = $_POST['location'];
	}
	
		if (empty($_POST['employee'])) {
		$errors[] = 'You forgot to enter a employee.';
	} else {
		$off = $_POST['employee'];
	}
	
		if (empty($_POST['sent_date'])) {
		$errors[] = 'You forgot to enter a sent date.';
	} else {
		$sd = $_POST['sent_date'];
	}
		if (empty($_POST['oth_date'])) {
		$errors[] = 'You forgot to enter an other date.';
	} else {
		$oth = $_POST['oth_date'];
	}
	
		if (empty($_POST['due_attny'])) {
		$errors[] = 'You forgot to enter an att date.';
	} else {
		$atn = $_POST['due_attny'];
	}
	
	if (empty($errors)) { // If everything's OK.

		$query = "UPDATE psrinfo SET pacts='$pt', fname='$fn', lname='$ln', status='$st', location='$loc', employee='$off', sent_date='$sd', oth_date='$oth', assgn_date='$ad', interv_date='$iv', due_rev='$rv', due_suspo='$sus', due_clerk='$clk', due_attny='$atn', due_owner='$jdg'  WHERE fid=$id";
		$result = @mysql_query ($query); // Run the query.
		
		
				
	
	
	
	
	
	
	
				// Send mail according to location
		switch ($loc) {
			case 'central office':
				$sEmailAddress = 'co@truir.org';
			break;
			
			case 'offsite office':
				$sEmailAddress = 'off@truir.org';
			break;
		}
		mail($sEmailAddress, $sSubject, $sMessage, $sHeaders);
		
		$sMessage = "<p>Someone has edited the information below.</p><br> Location : {$_REQUEST['location']}<br>First Name : {$_REQUEST['fname']}<br>Last Name : {$_REQUEST['lname']}";
		$sHeaders  = "MIME-Version: 1.0\n"; 
		$sHeaders .= "Content-type: text/html; charset=iso-8859-1\n"; 
		$subject  = "Please Review";
		$sHeaders .= "To: Supervisor <$sEmailAddress>\n"; 
		$sHeaders .= "From: The Database <sender email>\n"; 
		
		if (mail($sEmailAddress, $sSubject, $sMessage, $sHeaders)) {
		
		echo "<center>An email has been sent to the supervisor for review"; 
		
		} else { 
 
		echo "This system is not working properly. Please contact a tech."; 
 
		} 
	
	
	
	
	
	
	
	
	
	
	
	
		
		
		
		
		
		
		
		
		

$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
if ((substr($url, -1) == '/') OR (substr($url, -1) == '//')) {
$url = substr ($url, 0, -1);
}
$url ='/flow/index.html'; 

header("Location: $url");
exit();
		
	} else { // Report the errors.
	
		echo '<h1 id="mainhead">Error!</h1>
		<p class="error">The following error(s) occurred:<br />';
		foreach ($errors as $msg) { // Print each error.
			echo " - $msg<br />\n";
		}
		echo '</p><p>Please try again.</p><p><br /></p>';
		
	} // End of if (empty($errors)) IF.

} // End of submit conditional.

// Retrieve the user's information.
$query = "SELECT pacts, fname, lname, status, employee, location, assgn_date, interv_date, sent_date, oth_date, due_rev, due_suspo, due_clerk, due_attny, due_owner FROM psrinfo WHERE fid = " . $_REQUEST['id'];
$result = @mysql_query ($query); // Run the query.

if (mysql_num_rows($result) == 1) { 

	$row = mysql_fetch_array ($result, MYSQL_NUM);
	
?>	

<script type="text/javascript">
var valid;

function d2(v) { return (v<10)?("0"+v):v; }

function dcheck(form) {
var a = form.assgn_date.value;
var s = form.sent_date.value;
var i = form.interv_date.value;
var dr = form.due_rev.value
var su = form.due_suspo
var clk = form.due_clerk
var att = form.due_attny
var jdg = form.due_owner
var assn  = new Date(a);
var sent = new Date(s);
var intv = new Date(i);
var due_rev = new Date(dr);
var due_suspo = new Date(su);
var due_clerk = new Date(clk);
var due_attny = new Date(att);
var due_owner = new Date(jdg);


if (isNaN(intv)) {
intv = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()+0);
}
if (isNaN(assn)) {
assn = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()+0);
}
if (isNaN(due_rev)) {
due_rev = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-42);
}
if (isNaN(due_suspo)) {
due_suspo = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-40);
}
if (isNaN(due_clerk)) {
due_clerk = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-38);
}
if (isNaN(due_attny)) {
due_attny = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-36);
}
if (isNaN(due_owner)) {
due_owner = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-7);
}


switch(due_rev.getDay()){
  case 0: due_rev.setDate(due_rev.getDate() - 1); // take one for Sunday
  case 6: due_rev.setDate(due_rev.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_suspo.getDay()){
  case 0: due_suspo.setDate(due_suspo.getDate() - 1); // take one for Sunday
  case 6: due_suspo.setDate(due_suspo.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_clerk.getDay()){
  case 0: due_clerk.setDate(due_clerk.getDate() - 1); // take one for Sunday
  case 6: due_clerk.setDate(due_clerk.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_attny.getDay()){
  case 0: due_attny.setDate(due_attny.getDate() - 1); // take one for Sunday
  case 6: due_attny.setDate(due_attny.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_owner.getDay()){
  case 0: due_owner.setDate(due_owner.getDate() - 1); // take one for Sunday
  case 6: due_owner.setDate(due_owner.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_rev.getDay()){
  case 0: due_rev.setDate(due_rev.getDate() - 1); // take one for Sunday
  case 6: due_rev.setDate(due_rev.getDate() - 1); // take two for Sunday or one for Saturday
}

//form.assgn_date.value = (assn.getFullYear()+0) + "-" + d2(assn.getMonth()+1) + "-" + d2(assn.getDate());
//form.interv_date.value = (intv.getFullYear()+0) + "-" + d2(intv.getMonth()+1) + "-" + d2(intv.getDate());
form.sent_date.value = (sent.getFullYear()+0) + "-" + d2(sent.getMonth()+1) + "-" + d2(sent.getDate());
form.due_rev.value = (due_rev.getFullYear()+0) + "-" + d2(due_rev.getMonth()+1) + "-" + d2(due_rev.getDate());
form.due_suspo.value = (due_suspo.getFullYear()+0) + "-" + d2(due_suspo.getMonth()+1) + "-" + d2(due_suspo.getDate());
form.due_clerk.value = (due_clerk.getFullYear()+0) + "-" + d2(due_clerk.getMonth()+1) + "-" + d2(due_clerk.getDate());
form.due_attny.value = (due_attny.getFullYear()+0) + "-" + d2(due_attny.getMonth()+1) + "-" + d2(due_attny.getDate());
form.due_owner.value = (due_owner.getFullYear()+0) + "-" + d2(due_owner.getMonth()+1) + "-" + d2(due_owner.getDate());
return true;
}

</script>
<?php

echo '<form action="edit_assign.php" method="post">
<fieldset><legend><h1> You are editing a record!</h1></legend>

<b>PACTS No:</b> <br><input type="text" name="pacts" size="15" maxlength="30" value="'.$row[0].'" /><br>
<b>First Name:</b> <br><input type="text" name="fname" size="15" maxlength="30" value="'.$row[1].'" /><br />
<b>Last Name:</b> <br><input type="text" name="lname" size="15" maxlength="30" value="'.$row[2].'" /><br />
<b>Status: </b><br><input type="text" name="status" size="15" maxlength="30" value="'.$row[3].'" /> <br>
<b>Location: </b><br><input type="text" name="location" size="15" maxlength="30" value="'.$row[5].'" /><br>
<b>Employee: </b><br><input type="text" name="employee" size="15" maxlength="30" value="'.$row[4].'" /> <br>

<b>Sentence Date: MM/DD/YYYY </b><br><input type="text" name="sent_date" size="15" maxlength="30" value="'.$row[8].'" /> <br>

<p><input type="button" value="Calculate" onclick="return dcheck(this.form);">	

<b>-----------------------------------------------------------</b> <br /><br>

<b>Other Date:</b><br><input type="text" name="oth_date" size="15" maxlength="30" value="'.$row[9].'" /> <br>
<b>Assign Date:  </b><br><input type="text" name="assgn_date" size="15" maxlength="30" value="'.$row[6].'" /> <br>
<b>Interview Date:  </b><br><input type="text" name="interv_date" size="15" maxlength="30" value="'.$row[7].'" /> <br>
<b>Due to Reviewer:</b><br><input type="text" name="due_rev" size="15" maxlength="30" value="'.$row[10].'" /> <br>
<b>Due to SUSPO:</b><br><input type="text" name="due_suspo" size="15" maxlength="30" value="'.$row[11].'" /> <br>
<b>Due to Clerk:</b><br><input type="text" name="due_clerk" size="15" maxlength="30" value="'.$row[12].'" /> <br>
<b>Due to Att:</b><br><input type="text" name="due_attny" size="15" maxlength="30" value="'.$row[13].'" /> <br>
<b>Due to owner:</b><br><input type="text" name="due_owner" size="15" maxlength="30" value="'.$row[14].'" /> <br>
<br>
</fieldset>

<div align="left"><input type="submit" name="submit" value="Submit" /></div>

<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
</form>';

} else { 
	echo '<h1 id="mainhead">Page Error</h1>
	<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
}

mysql_close(); 

?>

Open in new window

0
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35157169
If you see the line below than the code is implemented correctly:
An email has been sent to the supervisor for review

Maybe it went to your spam folder?
0
 
LVL 15

Author Comment

by:wantabe2
ID: 35157320
Ahh....I am not getting "An email has been sent to the supervisor for review" after I submit it. Any clues why?
0
 
LVL 15

Author Comment

by:wantabe2
ID: 35157855
How can determine where the code is getting stopped?
0
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35157865
Put echo statements in severall places in your code.
0
 
LVL 15

Author Comment

by:wantabe2
ID: 35158914
I can put the code like you see in the attached & get several errors but I do see the confirmation message in the script. The errors are:

Undefined index: location in C:\wamp\www\flow\query\edit_dqa.php
Undefined index: fname in C:\wamp\www\flow\query\edit_dqa.php
Undefined index: lname in C:\wamp\www\flow\query\edit_dqa.php
Undefined variable: EmailAddress in C:\wamp\www\flow\query\edit_dqa.php
Warning: mail() [function.mail]: SMTP server response: 503 Issue RCPT TO: command before DATA command in C:\wamp\www\flow\query\edit_dqa.php
Notice: Use of undefined constant sendMail - assumed 'sendMail' in C:\wamp\www\flow\query\edit_dqa.php
<?php # edit_assign.php
$page_title = 'Edit a Record';

$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("psrflow", $con);

//$result = mysql_query("SELECT * FROM psrinfo ");

// Check for a valid user ID, through GET or POST.
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { 
	$id = $_GET['id'];
} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted.
	$id = $_POST['id'];
} else { // No valid ID, kill the script.
	echo '<h1 id="mainhead">Page Error</h1>
	<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
	include ('./includes/footer.html'); 
	exit();
}
// Check if the form has been submitted.

if (isset($_POST['submitted'])) {

	$errors = array(); // Initialize error array.

	if (empty($_POST['pacts'])) {
		$errors[] = 'You forgot to enter a PACTS number. If there is no PACTS # you can enter 0000';
	} else {
		$pt = $_POST['pacts'];
	}
	
	if (empty($_POST['fname'])) {
		$errors[] = 'You forgot to enter the first name.';
	} else {
		$fn = $_POST['fname'];
	}
	
	if (empty($_POST['lname'])) {
		$errors[] = 'You forgot to enter the last name.';
	} else {
		$ln = $_POST['lname'];
	}
	
	if (empty($_POST['status'])) {
		$errors[] = 'You forgot to enter a status.';
	} else {
		$st = $_POST['status'];
	}
	
	if (empty($_POST['assgn_date'])) {
		$errors[] = 'You forgot to enter an assign date.';
	} else {
		$ad = $_POST['assgn_date'];
	}
	
	if (empty($_POST['interv_date'])) {
		$errors[] = 'You forgot to enter an interview date.';
	} else {
		$iv = $_POST['interv_date'];
	}
	
		if (empty($_POST['due_rev'])) {
		$errors[] = 'You forgot to enter a due to reviewer date.';
	} else {
		$rv = $_POST['due_rev'];
	}
	
		if (empty($_POST['due_suspo'])) {
		$errors[] = 'You forgot to enter a due to SUSPO date.';
	} else {
		$sus = $_POST['due_suspo'];
	}
	
		if (empty($_POST['due_clerk'])) {
		$errors[] = 'You forgot to enter a due to clerk date.';
	} else {
		$clk = $_POST['due_clerk'];
	}
	
	
		if (empty($_POST['due_owner'])) {
		$errors[] = 'You forgot to enter a due to owner date.';
	} else {
		$jdg = $_POST['due_owner'];
	}
	
		if (empty($_POST['location'])) {
		$errors[] = 'You forgot to enter a location.';
	} else {
		$loc = $_POST['location'];
	}
	
		if (empty($_POST['employee'])) {
		$errors[] = 'You forgot to enter a employee.';
	} else {
		$off = $_POST['employee'];
	}
	
		if (empty($_POST['sent_date'])) {
		$errors[] = 'You forgot to enter a sent date.';
	} else {
		$sd = $_POST['sent_date'];
	}
		if (empty($_POST['oth_date'])) {
		$errors[] = 'You forgot to enter an other date.';
	} else {
		$oth = $_POST['oth_date'];
	}
	
		if (empty($_POST['due_attny'])) {
		$errors[] = 'You forgot to enter an att date.';
	} else {
		$atn = $_POST['due_attny'];
	}
	
	if (empty($errors)) { // If everything's OK.

		$query = "UPDATE psrinfo SET pacts='$pt', fname='$fn', lname='$ln', status='$st', location='$loc', employee='$off', sent_date='$sd', oth_date='$oth', assgn_date='$ad', interv_date='$iv', due_rev='$rv', due_suspo='$sus', due_clerk='$clk', due_attny='$atn', due_owner='$jdg'  WHERE fid=$id";
		$result = @mysql_query ($query); // Run the query.
		
		
					

$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
if ((substr($url, -1) == '/') OR (substr($url, -1) == '//')) {
$url = substr ($url, 0, -1);
}
$url ='/flow/index.html'; 

header("Location: $url");
exit();
		
	} else { // Report the errors.
	
		echo '<h1 id="mainhead">Error!</h1>
		<p class="error">The following error(s) occurred:<br />';
		foreach ($errors as $msg) { // Print each error.
			echo " - $msg<br />\n";
		}
		echo '</p><p>Please try again.</p><p><br /></p>';
		
	} // End of if (empty($errors)) IF.

} // End of submit conditional.

// Retrieve the user's information.
$query = "SELECT pacts, fname, lname, status, employee, location, assgn_date, interv_date, sent_date, oth_date, due_rev, due_suspo, due_clerk, due_attny, due_owner FROM psrinfo WHERE fid = " . $_REQUEST['id'];
$result = @mysql_query ($query); // Run the query.






				// Send mail according to location
		switch ($loc) {
			case 'central office':
				$sEmailAddress = 'co@truir.org';
			break;
			
			case 'offsite office':
				$sEmailAddress = 'off@truir.org';
			break;
		}
		mail($sEmailAddress, $sSubject, $sMessage, $sHeaders);
		
		$sMessage = "<p>Someone has edited the information below.</p><br> Location : {$_REQUEST['location']}<br>First Name : {$_REQUEST['fname']}<br>Last Name : {$_REQUEST['lname']}";
		$sHeaders  = "MIME-Version: 1.0\n"; 
		$sHeaders .= "Content-type: text/html; charset=iso-8859-1\n"; 
		$subject  = "Please Review";
		$sHeaders .= "To: Supervisor <$sEmailAddress>\n"; 
		$sHeaders .= "From: The Database <sender email>\n"; 
		
		if (mail($sEmailAddress, $sSubject, $sMessage, $sHeaders)) {
		
		echo "<center>An email has been sent to the supervisor for review"; 
		
		} else { 
 
		echo "This system is not working properly. Please contact a tech."; 
 
		} 












if (mysql_num_rows($result) == 1) { 

	$row = mysql_fetch_array ($result, MYSQL_NUM);
	
?>	

<script type="text/javascript">
var valid;

function d2(v) { return (v<10)?("0"+v):v; }

function dcheck(form) {
var a = form.assgn_date.value;
var s = form.sent_date.value;
var i = form.interv_date.value;
var dr = form.due_rev.value
var su = form.due_suspo
var clk = form.due_clerk
var att = form.due_attny
var jdg = form.due_owner
var assn  = new Date(a);
var sent = new Date(s);
var intv = new Date(i);
var due_rev = new Date(dr);
var due_suspo = new Date(su);
var due_clerk = new Date(clk);
var due_attny = new Date(att);
var due_owner = new Date(jdg);


if (isNaN(intv)) {
intv = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()+0);
}
if (isNaN(assn)) {
assn = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()+0);
}
if (isNaN(due_rev)) {
due_rev = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-42);
}
if (isNaN(due_suspo)) {
due_suspo = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-40);
}
if (isNaN(due_clerk)) {
due_clerk = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-38);
}
if (isNaN(due_attny)) {
due_attny = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-36);
}
if (isNaN(due_owner)) {
due_owner = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-7);
}


switch(due_rev.getDay()){
  case 0: due_rev.setDate(due_rev.getDate() - 1); // take one for Sunday
  case 6: due_rev.setDate(due_rev.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_suspo.getDay()){
  case 0: due_suspo.setDate(due_suspo.getDate() - 1); // take one for Sunday
  case 6: due_suspo.setDate(due_suspo.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_clerk.getDay()){
  case 0: due_clerk.setDate(due_clerk.getDate() - 1); // take one for Sunday
  case 6: due_clerk.setDate(due_clerk.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_attny.getDay()){
  case 0: due_attny.setDate(due_attny.getDate() - 1); // take one for Sunday
  case 6: due_attny.setDate(due_attny.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_owner.getDay()){
  case 0: due_owner.setDate(due_owner.getDate() - 1); // take one for Sunday
  case 6: due_owner.setDate(due_owner.getDate() - 1); // take two for Sunday or one for Saturday
}

switch(due_rev.getDay()){
  case 0: due_rev.setDate(due_rev.getDate() - 1); // take one for Sunday
  case 6: due_rev.setDate(due_rev.getDate() - 1); // take two for Sunday or one for Saturday
}

//form.assgn_date.value = (assn.getFullYear()+0) + "-" + d2(assn.getMonth()+1) + "-" + d2(assn.getDate());
//form.interv_date.value = (intv.getFullYear()+0) + "-" + d2(intv.getMonth()+1) + "-" + d2(intv.getDate());
form.sent_date.value = (sent.getFullYear()+0) + "-" + d2(sent.getMonth()+1) + "-" + d2(sent.getDate());
form.due_rev.value = (due_rev.getFullYear()+0) + "-" + d2(due_rev.getMonth()+1) + "-" + d2(due_rev.getDate());
form.due_suspo.value = (due_suspo.getFullYear()+0) + "-" + d2(due_suspo.getMonth()+1) + "-" + d2(due_suspo.getDate());
form.due_clerk.value = (due_clerk.getFullYear()+0) + "-" + d2(due_clerk.getMonth()+1) + "-" + d2(due_clerk.getDate());
form.due_attny.value = (due_attny.getFullYear()+0) + "-" + d2(due_attny.getMonth()+1) + "-" + d2(due_attny.getDate());
form.due_owner.value = (due_owner.getFullYear()+0) + "-" + d2(due_owner.getMonth()+1) + "-" + d2(due_owner.getDate());
return true;
}

</script>
<?php

echo '<form action="edit_assign.php" method="post">
<fieldset><legend><h1> You are editing a record!</h1></legend>

<b>PACTS No:</b> <br><input type="text" name="pacts" size="15" maxlength="30" value="'.$row[0].'" /><br>
<b>First Name:</b> <br><input type="text" name="fname" size="15" maxlength="30" value="'.$row[1].'" /><br />
<b>Last Name:</b> <br><input type="text" name="lname" size="15" maxlength="30" value="'.$row[2].'" /><br />
<b>Status: </b><br><input type="text" name="status" size="15" maxlength="30" value="'.$row[3].'" /> <br>
<b>Location: </b><br><input type="text" name="location" size="15" maxlength="30" value="'.$row[5].'" /><br>
<b>Employee: </b><br><input type="text" name="employee" size="15" maxlength="30" value="'.$row[4].'" /> <br>

<b>Sentence Date: MM/DD/YYYY </b><br><input type="text" name="sent_date" size="15" maxlength="30" value="'.$row[8].'" /> <br>

<p><input type="button" value="Calculate" onclick="return dcheck(this.form);">	

<b>-----------------------------------------------------------</b> <br /><br>

<b>Other Date:</b><br><input type="text" name="oth_date" size="15" maxlength="30" value="'.$row[9].'" /> <br>
<b>Assign Date:  </b><br><input type="text" name="assgn_date" size="15" maxlength="30" value="'.$row[6].'" /> <br>
<b>Interview Date:  </b><br><input type="text" name="interv_date" size="15" maxlength="30" value="'.$row[7].'" /> <br>
<b>Due to Reviewer:</b><br><input type="text" name="due_rev" size="15" maxlength="30" value="'.$row[10].'" /> <br>
<b>Due to SUSPO:</b><br><input type="text" name="due_suspo" size="15" maxlength="30" value="'.$row[11].'" /> <br>
<b>Due to Clerk:</b><br><input type="text" name="due_clerk" size="15" maxlength="30" value="'.$row[12].'" /> <br>
<b>Due to Att:</b><br><input type="text" name="due_attny" size="15" maxlength="30" value="'.$row[13].'" /> <br>
<b>Due to owner:</b><br><input type="text" name="due_owner" size="15" maxlength="30" value="'.$row[14].'" /> <br>
<br>
</fieldset>

<div align="left"><input type="submit" name="submit" value="Submit" /></div>

<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
</form>';

} else { 
	echo '<h1 id="mainhead">Page Error</h1>
	<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
}

mysql_close(); 

?>

Open in new window

0
 
LVL 8

Accepted Solution

by:
Rik-Legger earned 500 total points
ID: 35159320
You request the mail function 2 times (once on row 170 and once on row 179).
You should delete the first one because all the parameters are being set below.

Try echoing $sEmailAddress to see if it holds a emailaddress,
if not, check your switch case values.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question