Hi Jpadie...
Here is the actual code for both files...
You have been a great help with this...!!!
I know I could do this better, but I want it to work first, then I can clean up the way I have done this...
****** PARENT ***********
<?php include_once '../_library/DbConn.php';?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
<html xmlns="
<head>
<title>Site Administration Area</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<script language="javascript" type="text/javascript">
function openwindow(gotourl,name,w,h,scrollbars) {
window.open(gotourl,name,'width=' + w + ',height=' + h + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=no');
}
</script>
<?php
// connect to the database server
$connector = new DbConn();
if (isset($_POST['newsletter'])):
$ntitle = $_POST['newslettertitle'];
$aheading1 = $_POST['heading_1'];
$acontent1 = $_POST['content_1'];
$aheading2 = $_POST['heading_2'];
$acontent2 = $_POST['content_2'];
$aheading3 = $_POST['heading_3'];
$acontent3 = $_POST['content_3'];
$aheading4 = $_POST['heading_4'];
$acontent4 = $_POST['content_4'];
$aheading5 = $_POST['heading_5'];
$acontent5 = $_POST['content_5'];
// find templateid
$templateid = $_POST['templateid'];
// find subscribergroupid
$subscribergrpid = $_POST['subscribergroupid'];
// open article to insert contents
if ($aheading1 > ""){
$sql = $connector->query("INSERT INTO article SET
name = '" . htmlspecialchars($aheading1) . "',
story = '" . htmlspecialchars($acontent1) . "',
seq = 1");
if ($sql){
$article1 = mysql_insert_id();
$sqlxref = $connector->query("INSERT INTO articlexref SET
tableid = 1,
articleid = " . mysql_insert_id() . ",
recordid = " . $templateid);
}
}
if ($aheading2 > ""){
$sql = $connector->query("INSERT INTO article SET
name = '" . htmlspecialchars($aheading2) . "',
story = '" . htmlspecialchars($acontent2) . "',
seq = 2");
if ($sql){
$article2 = mysql_insert_id();
$sqlxref = $connector->query("INSERT INTO articlexref SET
tableid = 1,
articleid = " . mysql_insert_id() . ",
recordid = " . $templateid);
}
}
if ($aheading3 > ""){
$sql = $connector->query("INSERT INTO article SET
name = '" . htmlspecialchars($aheading3) . "',
story = '" . htmlspecialchars($acontent3) . "',
seq = 3");
if ($sql){
$article3 = mysql_insert_id();
$sqlxref = $connector->query("INSERT INTO articlexref SET
tableid = 1,
articleid = " . mysql_insert_id() . ",
recordid = " . $templateid);
}
}
if ($aheading4 > ""){
$sql = $connector->query("INSERT INTO article SET
name = '" . htmlspecialchars($aheading4) . "',
story = '" . htmlspecialchars($acontent4) . "',
seq = 4");
if ($sql){
$article4 = mysql_insert_id();
$sqlxref = $connector->query("INSERT INTO articlexref SET
tableid = 1,
articleid = " . mysql_insert_id() . ",
recordid = " . $templateid);
}
}
if ($aheading5 > ""){
$sql = $connector->query("INSERT INTO article SET
name = '" . htmlspecialchars($aheading5) . "',
story = '" . htmlspecialchars($acontent5) . "',
seq = 5");
if ($sql){
$article5 = mysql_insert_id();
$sqlxref = $connector->query("INSERT INTO articlexref SET
tableid = 1,
articleid = " . mysql_insert_id() . ",
recordid = " . $templateid);
}
}
// lookup templateid and pullout into a variable, then insert all the articles associated with that template.
// then save the template+articles into the newsletter table.
$tempsql = $connector->query("SELECT templatehtml
FROM subscribertemplate
WHERE templateid = " . $templateid);
$temphtml = $connector->fetchArray($tempsql);
$templatehtml = $temphtml['templatehtml'];
$articlearray = array($aheading1 . "<br/>" . $acontent1, $aheading2 . "<br/>" . $acontent2, $aheading3 . "<br/>" . $acontent3, $aheading4 . "<br/>" . $acontent4, $aheading5 . "<br/>" . $acontent5);
$zonearray = array("<zone1>","<zone2>","<zone3>","<zone4>","<zone5>");
$ntemplatehtml = str_replace($zonearray,$articlearray,$templatehtml);
$nsql = $connector->query("INSERT INTO newsletter SET
subscribergroupid = " . $subscribergrpid . ",
name = '" . $ntitle . "',
newsletterdate = CURDATE(),
htmlbody = '" . $ntemplatehtml . "',
sent = 0");
if ($nsql) {
$newsletterid = mysql_insert_id();
$nxref1 = $connector->query("INSERT INTO articlexref SET
tableid = 2,
articleid = " . $article1 . ",
recordid = " . $newsletterid);
$nxref2 = $connector->query("INSERT INTO articlexref SET
tableid = 2,
articleid = " . $article2 . ",
recordid = " . $newsletterid);
$nxref3 = $connector->query("INSERT INTO articlexref SET
tableid = 2,
articleid = " . $article3 . ",
recordid = " . $newsletterid);
$nxref4 = $connector->query("INSERT INTO articlexref SET
tableid = 2,
articleid = " . $article4 . ",
recordid = " . $newsletterid);
$nxref5 = $connector->query("INSERT INTO articlexref SET
tableid = 2,
articleid = " . $article5 . ",
recordid = " . $newsletterid);
echo("<script language='javascript'>window.location='newsletters.php?uid=" . $_SESSION['ugid'] . "'</script>");
}
// insert newsletter title
?>
<?php
else:
?>
<div style="padding-left:10px;color:#000000;font-size:14px;">Add Newsletter</div>
<div align="center">
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" name="addnewsletter">
<input type="hidden" name="newsletter" value="yes" />
<?
$result = $connector->query("SELECT subscribertemplate.templateid, subscribertemplate.numofarticles, subscribertemplate.numofimages
, template.name, subscribergroup.subscribergroupid
FROM subscribertemplate, template, subscribergroup
WHERE subscribergroup.usergroupid = " . $_SESSION['ugid'] . "
AND subscribertemplate.templateid = template.templateid
AND subscribergroup.subscribergroupid = subscribertemplate.subscribergroupid");
$ii = 1;
while($template = $connector->fetchArray($result)) {
$tid = $template['templateid'];
$nofarticles = $template['numofarticles'];
$nofimages = $template['numofimages'];
$subid = $template['subscribergroupid'];
$tname = $template['name'];
if ($ii = 1){?>
<input type="hidden" name="templateid" value="<?=$tid?>"/>
<input type="hidden" name="subscribergroupid" value="<?=$subid?>"/>
<?} else { ?>
<label><?=$tname?></label><input type="radio" name="templatetype" value="<?=$tid?>" />
<input type="hidden" name="subscribergroupid" value="<?=$subid?>"/>
<?
}
$ii = $ii + 1;
}
?>
<table cellpadding="0" cellspacing="0" border="0" width="50%">
<tr>
<td style="text-align:right;" colspan="2"><input type="submit" value="Save Newsletter" style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000;" >
<input type="button" value="Cancel" style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000; "
onclick="location.href='newsletters.php?uid=<?=$_SESSION['ugid']?>';" /></td>
</tr>
<tr>
<td style="text-align:left;"><label>Issue Title</label></td>
<td style="text-align:left;"><input type="text" name="newslettertitle" value="" size="35" /></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td style="vertical-align:top;text-align:left;"><label>Article Heading 1</label></td>
<td style="text-align:left;"><input type="text" name="heading_1" value="" size="35" /></td>
</tr>
<tr>
<td style="vertical-align:top;text-align:left;"><label>Content 1</label></td>
<td style="text-align:left;">
<textarea style="font-family:Verdana,Arial;font-size:10px;" cols="35" rows="5" name="content_1"><?php
$sValue1 = stripslashes($_POST['FCKeditor1']);
echo($sValue1);?></textarea>
<input type="button" name="editor_1" value="Editor" onclick="openwindow('editcontent.php?content=1','',600,300,'no');"
style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000; "/></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td style="vertical-align:top;text-align:left;"><label>Article Heading 2</label></td>
<td style="text-align:left;"><input type="text" name="heading_2" value="" size="35" /></td>
</tr>
<tr>
<td style="vertical-align:top;text-align:left;"><label>Content 2</label></td>
<td style="text-align:left;">
<textarea style="font-family:Verdana,Arial;font-size:10px;" cols="35" rows="5" name="content_2"><?php
$sValue2 = stripslashes($_POST['FCKeditor2']);
echo($sValue2);?></textarea>
<input type="button" name="editor_2" value="Editor" onclick="openwindow('editcontent.php?content=2','',600,300,'no');"
style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000;" /></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td style="vertical-align:top;text-align:left;"><label>Article Heading 3</label></td>
<td style="text-align:left;"><input type="text" name="heading_3" value="" size="35" /></td>
</tr>
<tr>
<td style="vertical-align:top;text-align:left;"><label>Content 3</label></td>
<td style="text-align:left;">
<textarea style="font-family:Verdana,Arial;font-size:10px;" cols="35" rows="5" name="content_3"><?php
$sValue3 = stripslashes($_POST['FCKeditor3']);
echo($sValue3);?></textarea>
<input type="button" name="editor_3" value="Editor" onclick="openwindow('editcontent.php?content=3','',600,300,'no');"
style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000;" /></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td style="vertical-align:top;text-align:left;"><label>Article Heading 4</label></td>
<td style="text-align:left;"><input type="text" name="heading_4" value="" size="35" /></td>
</tr>
<tr>
<td style="vertical-align:top;text-align:left;"><label>Content 4</label></td>
<td style="text-align:left;">
<textarea style="font-family:Verdana,Arial;font-size:10px;" cols="35" rows="5" name="content_4"><?php
$sValue4 = stripslashes($_POST['FCKeditor4']);
echo($sValue4);?></textarea>
<input type="button" name="editor_4" value="Editor" onclick="openwindow('editcontent.php?content=4','',600,300,'no');"
style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000;" /></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td style="vertical-align:top;text-align:left;"><label>Article Heading 5</label></td>
<td style="text-align:left;"><input type="text" name="heading_5" value="" size="35" /></td>
</tr>
<tr>
<td style="vertical-align:top;text-align:left;"><label>Content 5</label></td>
<td style="text-align:left;">
<textarea style="font-family:Verdana,Arial;font-size:10px;" cols="35" rows="5" name="content_5"><?php
$sValue5 = stripslashes($_POST['FCKeditor5']);
echo($sValue5);?></textarea>
<input type="button" name="editor_5" value="Editor" onclick="openwindow('editcontent.php?content=5','',600,300,'no');"
style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000;" /></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td style="text-align:right;" colspan="2"><input type="submit" value="Save Newsletter" style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000;" />
<input type="button" value="Cancel" style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000; "
onclick="location.href='newsletters.php?uid=<?=$_SESSION['ugid']?>';" /></td>
</tr>
</form>
</table>
</div>
<?php endif; ?>
</body>
</html>
****** CHILD POPUP ******
<?php
include("../FCKeditor/fckeditor.php") ;
include_once '../_library/DbConn.php';
$contentid = $_GET['content'];
$articleid = $_GET['aid'];
$newsletterid = $_GET['nid'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>FCKeditor - Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<link href="../sample.css" rel="stylesheet" type="text/css" />
</head>
<body>
<hr>
<? if ($articleid > 0) {?>
<form action="content.php?content=<?=$contentid;?>&id=<?=$newsletterid;?>&edit=yes" method="post" target="content">
<?} else {?>
<form action="content.php?content=<?=$contentid;?>" method="post" target="content">
<?}
$sBasePath = $_SERVER['PHP_SELF'] ;
$sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "FCKeditor" ) ) ;
$oFCKeditor = new FCKeditor('FCKeditor' . $contentid) ;
$oFCKeditor->BasePath = '../FCKeditor/';//$sBasePath ;
// connect to the database server
$connector = new DbConn();
$query = $connector->query("SELECT article.story
FROM article, newsletter, articlexref
WHERE newsletter.newsletterid = " . $newsletterid . "
AND article.articleid = " . $articleid . "
AND articlexref.articleid = article.articleid
AND articlexref.recordid = newsletter.newsletterid");
if ($query) {
$content = $connector->fetchArray($query);
$acontent = stripslashes($content['story']);
$oFCKeditor->Value = $acontent;
} else {
$oFCKeditor->Value = '';
}
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '200' ;
$oFCKeditor->Create() ;
?>
<br>
<input type="submit" value="Submit" style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000; " />
<? if ($articleid > 0) {?>
<input type="button" value="Cancel" style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000; "
onclick="location.href='content.php?id=<?=$newsletterid;?>';window.close();" />
<?} else {?>
<input type="button" value="Cancel" style="font-family: Verdana; font-size: 8pt; color: #000000; background-color: #ffffff; border: 1px solid #000000; "
onclick="location.href='content.php';window.close();" />
<?}
?>
</form>
</body>
</html>