
23-May-2004, 12:58
|
|
New Member
|
|
Join Date: May 2004
Posts: 2
|
|
|
Posting Problem
Thanks! It's working now. By the way, could check the below script too.
PHP Code:
<?
include("config_file.php");
//**DEBUG**//
//echo($type.' '.$user_id);
//$ii=($HTTP_POST_VARS['subcategory_id']);
//postvars($HTTP_POST_VARS);
//**DEBUG**//
if ($type=="sellers")
{
$table_name = $bx_db_table_sellers;
}
else
{
}
$sel = bx_db_query("select * from $table_name where user_id='$user_id'");
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
if(bx_db_num_rows($sel)!=0)
{
$result = bx_db_fetch_array($sel);
}
//verify seller pay status
if ($result['pay_status']=="yes")
{
$SQL = "select * from $bx_db_table_email_notification where user_type='sellers' and user_id=$user_id";
$notification_query = bx_db_query($SQL);
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
$res_notification=bx_db_fetch_array($notification_query);
//**If user is not in table**//
if ($HTTP_POST_VARS['update']=="Update" and ($HTTP_POST_VARS['notification_enter']=="
notification_enter") and $res_notification=='')
{
$category_list=$HTTP_POST_VARS['subcategory_id'];
$category_notification_string=",";
for ($i=0;$i < (count($HTTP_POST_VARS['subcategory_id'])) ;$i++ )
{
$category_notification_string.=$category_list[$i];
$category_notification_string.=",";
}
$insertSQL = "insert into $bx_db_table_email_notification values('','".$user_id."','".$type."
','".$category_notification_string."','".$HTTP_POST_VARS['bid_notification']."','".$HTTP_POST_VARS[
'message_notification']."','".$HTTP_POST_VARS['newsletter_notification']."')";
$insert_query = bx_db_query($insertSQL);
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
}
//**If user is already in table**//
if ($HTTP_POST_VARS['update']=="Update" and ($HTTP_POST_VARS['notification_enter']=="
notification_enter") and $res_notification!='')
{
$category_list=$HTTP_POST_VARS['subcategory_id'];
$category_notification_string=",";
for ($i=0;$i < (count($HTTP_POST_VARS['subcategory_id'])) ;$i++ )
{
$category_notification_string.=$category_list[$i];
$category_notification_string.=",";
}
$updateSQL = "update $bx_db_table_email_notification set category_notification='".
$category_notification_string."', bid_notification='".$HTTP_POST_VARS['bid_notification']."',
message_notification='".$HTTP_POST_VARS['message_notification']."', newsletter_subscribe='".
$HTTP_POST_VARS['newsletter_notification']."' where user_id='".$user_id."' and user_type='".$type."'";
$update_query = bx_db_query($updateSQL);
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
}
//**Subscribe to newsletter**//
if ($HTTP_POST_VARS['update']=="Update" and ($HTTP_POST_VARS['notification_enter']=="
notification_enter") and ($HTTP_POST_VARS['newsletter_notification']=="1"))
{
$x="bx_db_table_".$type;
$xtable=$$x;
$SQL = "select * from $xtable where user_id='".$user_id."'";
$sel_email = bx_db_query($SQL);
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
$res_email=bx_db_fetch_array($sel_email);
$SQL = "select * from $bx_db_table_newsletter_subscribers where email='".$res_email['email']."'";
$sel = bx_db_query($SQL);
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
if(bx_db_num_rows($sel)==0)
{
$SQL = "insert into $bx_db_table_newsletter_subscribers values('','".$res_email['email']."
','daily',now(),'active')";
$ins = bx_db_query($SQL);
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
}
}
//**Unsubscribe from newsletter**//
if ($HTTP_POST_VARS['update']=="Update" and ($HTTP_POST_VARS['notification_enter']=="
notification_enter") and ($HTTP_POST_VARS['newsletter_notification']=="0"))
{
$x="bx_db_table_".$type;
$xtable=$$x;
$SQL = "select * from $xtable where user_id='".$user_id."'";
$sel_email = bx_db_query($SQL);
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
$res_email=bx_db_fetch_array($sel_email);
$SQL = "select * from $bx_db_table_newsletter_subscribers where email='".$res_email['email']."'";
$sel = bx_db_query($SQL);
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
if(bx_db_num_rows($sel) > 0)
{
$SQL = "DELETE FROM $bx_db_table_newsletter_subscribers where email='".$res_email['email']."'";
$ins = bx_db_query($SQL);
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
}
}
$SQL = "select * from $bx_db_table_email_notification where user_type='sellers' and user_id=$user_id";
$notification_query = bx_db_query($SQL);
SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1));
$res_notification=bx_db_fetch_array($notification_query);
//**'Checked' variables for radio inputs**//
if ($res_notification=='')
{
$bid_notif_sel="checked";
$bid_notif_unsel="";
$message_notif_sel="checked";
$message_notif_unsel="";
$newsletter_notif_sel="checked";
$newsletter_notif_unsel="";
}else{
if ($res_notification['bid_notification']=='1')
{
$bid_notif_sel="checked";
$bid_notif_unsel="";
}else{
$bid_notif_sel="";
$bid_notif_unsel="checked";
}
if ($res_notification['message_notification']=='1')
{
$message_notif_sel="checked";
$message_notif_unsel="";
}else{
$message_notif_sel="";
$message_notif_unsel="checked";
}
if ($res_notification['newsletter_subscribe']=='1')
{
$newsletter_notif_sel="checked";
$newsletter_notif_unsel="";
}else{
$newsletter_notif_sel="";
$newsletter_notif_unsel="checked";
}
$bid_notif_sel="checked";
$message_notif_sel="";
$message_notif_sel="checked";
$newsletter_notif_sel="";
$newsletter_notif_sel="checked";
}
?>
<br>
<table border="0" cellpadding="1" cellspacing="0" bgcolor="<?=REGISTRATION_FORM_BORDER_COLOR?>" align
="center" width="<?echo TABLE_WIDTH;?>">
<tr>
<td>
<table border="0" cellpadding="4" cellspacing="0" align="center" bgcolor="<?=
REGISTRATION_FORM_BODY_BGCOLOR?>" width="100%">
<form method="post" action="e_notification.php" enctype="multipart/form-data">
<tr bgcolor="<?=REGISTRATION_FORM_HEAD_BGCOLOR?>"><td colspan="2" height="15" align="center"
><font color="<?=REGISTRATION_FORM_HEAD_TEXT_COLOR?>" class="text1"><b>Email Notifications</b></font><
/td></tr>
<tr><td class="text1" colspan="2">Change your subscription settings for emails from
ConnectPlace </td></tr>
<tr><td colspan="2" class="text1"><br><u><b>Administrative Emails</b></u></td></tr>
<tr><td class="text1" colspan="2">Receive an email whenever a project you are interested in is
posted.</td></tr>
<tr><td class="text1" colspan="2">You can <b>select</b> or <b>deselect</b> more than one
category by holding down the CTRL key.<br></td></tr>
<tr><td width="20%"> </td><td>
<select name="subcategory_id[]" SIZE=4 MULTIPLE>
<?
$SQL = "select * from $bx_db_table_project_category order by category_name";
$category_select_query = bx_db_query($SQL);
$i = 0;
if(bx_db_num_rows($category_select_query))
while ($category_select_result = bx_db_fetch_array($category_select_query))
{
$SQL = "select * from $bx_db_table_project_subcategory where category_id='".
$category_select_result['category_id']."'";
$subcategory_select_query = bx_db_query($SQL);
if ($count_subcategory = bx_db_num_rows($subcategory_select_query))
while ($subcategory_select_result = bx_db_fetch_array($subcategory_select_query))
{
echo "<option value='".$subcategory_select_result['subcategory_id']."' ";
//echo $category_select_result['category_id'];
//exit;
if ((ereg(",".$subcategory_select_result['subcategory_id'].","
,$res_notification['category_notification'])))
{
echo "selected";
}
echo">".$category_select_result['category_name'].": ".
$subcategory_select_result['subcategory_name']."</option>";
}
}
?>
</select>
</td></tr>
<!-- <tr><td class="text1" colspan="2">Receive an email regarding a bid you've placed on a
project (e.g. bid is declined).<br></td></tr>
<tr><td width="20%"> </td><td class="text1"><input type="radio" name="bid_notification"
value="1" <?=$bid_notif_sel?>>Subscribe<br>
<input type="radio" name="bid_notification" value="0" <?=$bid_notif_unsel?>>Unsubscribe</td></
tr> -->
<tr><td class="text1" colspan="2">Receive an email when a new message is posted on your private
message board.<br></td></tr>
<tr><td width="20%"> </td><td class="text1"><input type="radio" name="
message_notification" value="1" <?=$message_notif_sel?>>Subscribe<br>
<input type="radio" name="message_notification" value="0" <?=$message_notif_unsel?
>>Unsubscribe</td></tr>
<tr><td colspan="2" class="text1"><br><u><b>Newsletter Emails</b></u></td></tr>
<tr><td class="text1" colspan="2">Receive newsletter emails from CP.<br></td></tr>
<tr><td width="20%"> </td><td class="text1"><input type="radio" name="
newsletter_notification" value="1" <?=$newsletter_notif_sel?>>Subscribe<br>
<input type="radio" name="newsletter_notification" value="0" <?=$newsletter_notif_unsel?
>>Unsubscribe</td></tr>
<input type="hidden" name="notification_enter" value="notification_enter">
<tr><td align="center" colspan="2"><input type="submit" class="button" name="update" value="
Update"></td></tr>
</td></tr>
</form>
</table>
</td>
</tr>
</table><br>
<?
}//$result['pay_status']=="yes"
else
{
?>
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0" height="100">
<tr>
<td class="text1" align="center"><font color="<?echo ERROR_TEXT_COLOR?>">You cannot
access this section because your payment was not finished! Click <a href="<?=HTTP_SERVER?
>/my_account.php" class="head"><b>here</b></a> to access the payment form!</font></td>
</tr>
</table>
<?
}
include (DIR_FORMS."footer.php");
?>
--------------------------------------------------------------------------
Regards,
John
|