hi there .. this is my question how do i combine this two code together .. 1 is the sending of email code, the other is the page where i can click on submit email and the mail will be generated and send to the user ...
1. email code
$query = "SELECT * FROM Auth.Auth, Staff.Staff from Auth, Staff where Auth.staffID = Staff.staffID";
$result = mysql_query ($query, $mysql_connection) or die(mysql_error());
// There is only one matching row
$row = mysql_fetch_array($result)
;
// Start by setting up the "to" address
$to = $row["staffName"] . " " .
$row["staffID"] . ">";
// Now, setup the "subject" line
$subject = "<p align=center class='text'><b>Account Confirmation</b></p>";
// Now, put together the body of the email
$out = "<p class='text'>Dear User,<br>" .
"<br>Welcome to Infused Computer Fault System<br>";
$out.= "<br>Your account (reference#" . $authID .") has been created successfully. " ;
$mail = mail(" ".$row["email"]. " ",
"Infused Solution Computer Fault System Reference No.",
"Your account (reference#" . $authID ." )has been created successfully. " .
" Your User ID ( ".$staffID.") and Password (".password." )" .
"Please quote this reference number in any correspondence. " ,
"From: The CFS Team");
2. Page to submit the email
<?php
include ("topbar.php");
?>
<body>
<table width="800" border="0" align="center">
<tr>
<td><table width="334" border="0
" align="left" cellpadding="1">
<tr></tr>
<td colspan="2"><span class="style1">Register Account</span></td>
</tr><form action="addaccountconfirm.
php" method="post">
<?
print("<tr>");
print("<td align=left>Department:  ");
print("<td>");
$query = "select * from Department order by deptName";
$query_result = mysql_query ($query, $mysql_connection);
print("<form action='staffaddconfirm.ph
p' method=POST name='department'>");
// Use a droplist to display all categories from the Category table
$displaydepartment = "<select name='deptID' onchange='return refresh_page(this.value)'>
<option value=0> -- Select One -- </option>";
while ($departmentlist = mysql_fetch_array($query_r
esult))
{
$deptID = $departmentlist["deptID"];
$deptName = $departmentlist["deptName"
];
if (!empty($_GET['deptID']))
{
// $displaydepartment .= "<option value = ".$deptID.">".$deptName."<
/option>";
$displaydepartment .= "<option value ='".$deptID."' ". ($deptID==$_REQUEST["deptI
D"]?"selec
ted":"")."
>".$deptNa
me."</opti
on>";
}
else
{
//$displaydepartment .= "<option value ='".$deptID."' ". ($deptID==$_REQUEST["deptI
D"]?"selec
ted":"")."
>".$deptNa
me."</opti
on>";
$displaydepartment .= "<option value = ".$deptID.">".$deptName."<
/option>";
}
}
$displaydepartment .= "</select>";
print $displaydepartment;
?>
<tr>
<td><div align="left">Staff Name: </div></td>
<td>
<?
if (!empty($_GET['deptID']))
{
$query1 = "select * from Staff where deptID='".$_REQUEST["deptI
D"]."' order by staffName";
// $query1 = "select * from Staff where deptID= '$deptID' order by staffName";
$query_result1 = mysql_query ($query1, $mysql_connection);
}
else
{
$query1 = "select * from Staff where deptID= '0' order by staffName";
$query_result1 = mysql_query ($query1, $mysql_connection);
}
print("<form action='staffaddconfirm.ph
p' method=POST>");
// Use a droplist to display all categories from the Category table
$displaystaff = "<select name='staffID'> <option value=0> -- Select One -- </option>";
while ($stafflist = mysql_fetch_array($query_r
esult1))
{
$staffID = $stafflist["staffID"];
$staffName = $stafflist["staffName"];
$displaystaff .= "<option value = ".$staffID.">".$staffName.
"</option>
";
}
$displaystaff .= "</select>";
print $displaystaff;
?>
</td>
</tr>
<tr>
<td><div align="left">Password:</di
v></td>
<td><input type="password" name="apass"></td>
</tr>
<tr>
<td><div align="left">Re-Type Password: </div></td>
<td><input type="password" name="repass"></td>
</tr>
<tr>
<td><div align="left">Account Type: </div></td>
<? $query1 = "select * from Account_Type order by accountType";
$query_result1 = mysql_query ($query1, $mysql_connection); ?>
<td>
<? $displayaccountType = "<select name='accountType'> <option value=0> -- Select -- </option>";
while ($accountTypelist = mysql_fetch_array($query_r
esult1))
{
$accountType = $accountTypelist["accountT
ype"];
$displayaccountType .= "<option value = '.accountType.'>".$account
Type."</op
tion>";
}
$displayaccountType .= "</select>";
print $displayaccountType;
?>
</td>
</tr>
<tr>
<td align="center">
<div align="left"> </div>
<input name="Clear2" type="reset" id="Clear" value="Clear"><input type="submit" name="Submit2" value="Submit"></td>
</td>
</tr>
<tr>
<td colspan="2" align="right"> </td>
</tr>
</table>
</tr>
</table>
</form>
</body>
</html>
<?php
include ("bottombar.php");
?>
<script language="javascript">
function refresh_page(dept_id)
{
top.location.href= "addaccount.php?deptID=" + dept_id; //change department.php with your php file name
return false;
}
</script>
thanks