What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Help with ASP; Web programming.

Help with ASP; Web programming.
Author: Message:
dotNorma
Veteran Member
*****

Avatar

Posts: 1745
Reputation: 17
33 / Male / –
Joined: May 2003
O.P. Undecided  Help with ASP; Web programming.
Well, I didnt want to post this on the forums but, I hate web coding and I cant ever get anywhere with it.

Anyhow, I was wondering if any of yall could help me out with this.

http://noname.big-blue-fish.com/source.php

code:
<?php
//adv_mailer.php

function mailer_header()
{
?>
<HTML>
<HEAD><TITLE>PHP Mailer 0.01</TITLE></HEAD>
<BODY>
<center><h2><b>PHP Mailer 0.01</b></h2></center><?php
}

function mailer_footer()
{
?>
</BODY>
</HTML>
<?php
}

function error_message($msg)
{
   mailer_header();
   echo "<SCRIPT>alert(\"Error: $msg\");history.go(-1)</SCRIPT>";
   mailer_footer();
   exit;
}

function user_message($msg)
{
   mailer_header();
   echo "<SCRIPT>alert(\"$msg\");history.go(-1)</SCRIPT>";
   mailer_footer();
   exit;
}

function mail_form() {
   global $PHP_SELF;
?>
<FORM METHOD="POST" ENCTYPE="MULTIPART/FORM-DATA" ACTION="<?php echo $PHP_SELF ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="send_mail">
<DIV ALIGN="CENTER ">
<TABLE CELLSPACING="2" CELLPADDING="5" WIDTH="90%" BORDER="1">
   <TR>

      <TH ALIGN="CENTER" WIDTH="30%">To</TH>
      <TD WIDTH="70%"><INPUT NAME="mail_to" SIZE="20"></TD>
   </TR>
   <TR>
      <TH ALIGN="CENTER" WIDTH="30%">Cc</TH>
      <TD WIDTH="70%"><INPUT NAME="mail_cc" SIZE="20"></TD>
   </TR>
   <TR>

      <TH ALIGN="CENTER" WIDTH="30%">Bcc</TH>
      <TD WIDTH="70%"><INPUT NAME="mail_bcc" SIZE="20"></TD>
   </TR>
   <TR>
      <TH ALIGN="CENTER" WIDTH="30%">From</TH>
      <TD WIDTH="70%"><INPUT SIZE="20" NAME="mail_from"></TD>
   </TR>
   <TR>
      <TH ALIGN="CENTER" WIDTH="30%">Reply-to</TH>
      <TD WIDTH="70%"><INPUT SIZE="20" NAME="mail_reply_to"></TD>
   </TR>
   <TR>
      <TH ALIGN="CENTER" WIDTH="30%">Attachment</TH>
      <TD WIDTH="70%"><INPUT TYPE="FILE" NAME="userfile"></TD>
   </TR>
   <TR>
      <TH ALIGN="CENTER" WIDTH="30%">Type</TH>
      <TD WIDTH="70%">
      <INPUT TYPE="RADIO" VALUE="text" NAME="mail_type" CHECKED>TEXT
      <INPUT TYPE="RADIO" VALUE="html" NAME="mail_type">HTML</TD>
   </TR>
   <TR>
      <TH ALIGN="CENTER" WIDTH="30%">Encoding</TH>
      <TD WIDTH="70%">
      <INPUT TYPE="RADIO" VALUE="7bit" NAME="mail_encoding" CHECKED>7BIT
      <INPUT TYPE="RADIO" VALUE="8bit" NAME="mail_encoding">8BIT</TD>
   </TR>
   <TR>
      <TH ALIGN="CENTER" WIDTH="30%">Character Set</TH>
      <TD WIDTH="70%">
      <INPUT TYPE="RADIO" VALUE="us-ascii" NAME="mail_charset" CHECKED>US-ASCII
      <INPUT TYPE="RADIO" VALUE="euc-kr" NAME="mail_charset">EUC-KR</TD>
   </TR>
   <TR>
      <TH ALIGN="CENTER" WIDTH="30%">Subject</TH>
      <TD WIDTH="70%"><INPUT SIZE="40" NAME="mail_subject"></TD>
   </TR>
   <TR>

      <TH ALIGN="CENTER" WIDTH="30%">Body</TH>
      <TD WIDTH="70%"><TEXTAREA NAME="mail_body" ROWS="16"
         COLS="70"></TEXTAREA></TD>
   </TR>
   <TR>
      <TH WIDTH="100%" COLSPAN="2" ALIGN="CENTER">
         <INPUT TYPE="SUBMIT" VALUE="Send" NAME="SUBMIT">
         <INPUT TYPE="RESET" VALUE="Reset" NAME="RESET">
      </TH>

   </TR>
</TABLE>
</DIV>
</FORM>
<?php
}

function send_mail()
{
   global $mail_to, $mail_cc, $mail_bcc, $mail_from, $mail_reply_to;
   global $mail_body, $mail_subject;
   global $userfile, $userfile_type, $userfile_name, $userfile_size;
   global $mail_type, $mail_charset, $mail_encoding;

   $mail_parts["mail_type"] = $mail_type;
   $mail_parts["mail_charset"] = $mail_charset;
   $mail_parts["mail_encoding"] = $mail_encoding;

   $mail_parts["userfile"] = $userfile;
   $mail_parts["userfile_type"] = $userfile_type;
   $mail_parts["userfile_name"] = $userfile_name;
   $mail_parts["userfile_size"] = $userfile_size;


   $mail_parts["mail_to"] = $mail_to;
   $mail_parts["mail_from"] = $mail_from;
   $mail_parts["mail_reply_to"] = $mail_reply_to;
   $mail_parts["mail_cc"] = $mail_cc;
   $mail_parts["mail_bcc"] = $mail_bcc;
   $mail_parts["mail_subject"] = trim($mail_subject);
   $mail_parts["mail_body"] = $mail_body;

   if(my_mail($mail_parts))
      user_message("Successfully sent an e-mail titled '$mail_subject'.");
        else error_message("An unknown error occurred while attempting to
                                 send an e-mail titled '$mail_subject'.");
}

function my_mail($mail_parts)
{
   $mail_to = $mail_parts["mail_to"];
   $mail_from = $mail_parts["mail_from"];
   $mail_reply_to = $mail_parts["mail_reply_to"];
   $mail_cc = $mail_parts["mail_cc"];
   $mail_bcc = $mail_parts["mail_bcc"];
   $mail_subject = $mail_parts["mail_subject"];
   $mail_body = $mail_parts["mail_body"];

   $mail_type = $mail_parts["mail_type"];
   $mail_charset = $mail_parts["mail_charset"];
   $mail_encoding = $mail_parts["mail_encoding"];

   $userfile = $mail_parts["userfile"];
   $userfile_type = $mail_parts["userfile_type"];
   $userfile_name = $mail_parts["userfile_name"];
   $userfile_size = $mail_parts["userfile_size"];

   if(empty($mail_to)) error_message("Empty to field!");
   if(empty($mail_subject)) error_message("Empty subject!");
   if(empty($mail_body)) error_message("Empty body! ");

   $mail_to = str_replace(";", ",", $mail_to);

   $mail_headers = '';

   if(!empty($mail_from)) $mail_headers .= "From: $mail_from\n";
   if(!empty($mail_reply_to)) $mail_headers .= "Reply-to: $mail_reply_to\n";
   if(!empty($mail_cc))
            $mail_headers .= "Cc: " . str_replace(";", ",", $mail_cc) . "\n";
   if(!empty($mail_bcc))
            $mail_headers .= "Bcc: " . str_replace(";", ",", $mail_bcc) . "\n";

   $mail_subject = stripslashes($mail_subject);
   $mail_body = stripslashes($mail_body);

   if($userfile_size > 0)
   {
      $mail_boundary = md5(uniqid(time()));
      $mail_headers .= "MIME-Version: 1.0\r\n";
      $mail_headers .= "Content-type: multipart/mixed;
                                      boundary=\"$mail_boundary\"\r\n\r\n";
      $mail_headers .= "This is a multi-part message in MIME format.\r\n\r\n";

      $fp = fopen($userfile, "r");
      $file = fread($fp, filesize($userfile));
      $file = chunk_split(base64_encode($file));

      $new_mail_body = "--$mail_boundary\r\n";
      $new_mail_body .= "Content-type:text/plain;charset=$mail_charset\r\n";
      $new_mail_body .= "Content-transfer-encoding:$mail_encoding\r\n\r\n";
      $new_mail_body .= "$mail_body\r\n";
      $new_mail_body .= "--$mail_boundary\r\n";
      if(!empty($userfile_type)) $mime_type = $userfile_type;
      else $mime_type = "application/octet-stream";

      $new_mail_body .= "Content-type:$mime_type;name=$userfile_name\r\n";
      $new_mail_body .= "Content-transfer-encoding:base64\r\n\r\n";
      $new_mail_body .= $file . "\r\n\r\n";
      $new_mail_body .= "--$mail_boundary--";
      $mail_body = $new_mail_body;
   }
   else if($mail_type == 'html')
   {
      $mail_headers .= "Content-type: text/html; charset=$mail_charset\r\n";
      $mail_headers .= "Content-transfer-encoding:$mail_encoding\r\n\r\n";
   }
   else
   {
      $mail_headers .= "Content-type: text/plain; charset=$mail_charset\r\n";
      $mail_headers .= "Content-transfer-encoding:$mail_encoding\r\n\r\n";
   }

   return mail($mail_to,$mail_subject,$mail_body,$mail_headers);
}

switch ($action)
{
   case "send_mail":
      mailer_header();
      send_mail();
      mailer_footer();
      break;
   case "mail_form":
      mailer_header();
      mail_form();
      mailer_footer();
      break;
   default:
      mailer_header();
      mail_form();
      mailer_footer();
      break;
}
?>


What I want to do is make it so that the only visible forms are the "To:" and the "Body:", I want the rest to not be shown but have their variables set to the default (Except instead of text I think it should be html for the type). And I want to be able to declare the From email and the subject as something I can change. Sorry, I didnt want to come on here but I suck at web coding.

I think thats clear? Anyhow, Thanks for help.
08-26-2005 02:50 AM
Profile PM Web Find Quote Report
brian
Senior Member
****

Avatar

Posts: 819
Reputation: 43
– / Male / –
Joined: Sep 2004
RE: Help with ASP; Web programming.
You really have no clue, it's not even ASP. :chrongue:

Anyways, I did it as you want, with some configuration.

code:
<?php

////////////////////////////////////////////////////////////////////////////////////////////////
$mailfrom = "this.is.the.email.which.will.be.in.from.but.wont.be.visible@hai2u.com";
$mailsubject = "this will be the subject, that they wont be able to set, but it is here, hax!";
////////////////////////////////////////////////////////////////////////////////////////////////


function mailer_header()
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD><TITLE>PHP Mailer 0.01</TITLE></HEAD>
<BODY>
<center><h2><b>PHP Mailer 0.01</b></h2></center><?php
}

function mailer_footer()
{
?>
</BODY>
</HTML>
<?php
}

function error_message($msg)
{
   mailer_header();
   echo "<SCRIPT>alert(\"Error: $msg\");history.go(-1)</SCRIPT>";
   mailer_footer();
   exit;
}

function user_message($msg)
{
   mailer_header();
   echo "<SCRIPT>alert(\"$msg\");history.go(-1)</SCRIPT>";
   mailer_footer();
   exit;
}

function mail_form() {
   global $PHP_SELF;
?>
<FORM METHOD="POST" ENCTYPE="MULTIPART/FORM-DATA" ACTION="<?php echo $_SERVER['PHP_SELF']; ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="send_mail">
<DIV ALIGN="CENTER ">
<TABLE CELLSPACING="2" CELLPADDING="5" WIDTH="90%" BORDER="1">
   <TR>

      <TH ALIGN="CENTER" WIDTH="30%">To</TH>
      <TD WIDTH="70%"><INPUT NAME="mail_to" SIZE="20"></TD>
   </TR>
      <INPUT TYPE="HIDDEN" NAME="mail_from" VALUE="<?php echo $mailfrom; ?>">
      <INPUT TYPE="HIDDEN" VALUE="html" NAME="mail_type">
      <INPUT TYPE="HIDDEN" VALUE="7bit" NAME="mail_encoding">
      <INPUT TYPE="HIDDEN" VALUE="us-ascii" NAME="mail_charset">
      <INPUT TYPE="HIDDEN" NAME="mail_subject" VALUE="<?php echo $mailsubject; ?>"></TD>
   </TR>
   <TR>

      <TH ALIGN="CENTER" WIDTH="30%">Body</TH>
      <TD WIDTH="70%"><TEXTAREA NAME="mail_body" ROWS="16"
         COLS="70"></TEXTAREA></TD>
   </TR>
   <TR>
      <TH WIDTH="100%" COLSPAN="2" ALIGN="CENTER">
         <INPUT TYPE="SUBMIT" VALUE="Send" NAME="SUBMIT">
         <INPUT TYPE="RESET" VALUE="Reset" NAME="RESET">
      </TH>

   </TR>
</TABLE>
</DIV>
</FORM>
<?php
}

function send_mail()
{
   global $mail_to, $mail_cc, $mail_bcc, $mail_from, $mail_reply_to;
   global $mail_body, $mail_subject;
   global $userfile, $userfile_type, $userfile_name, $userfile_size;
   global $mail_type, $mail_charset, $mail_encoding;

   $mail_parts["mail_type"] = $mail_type;
   $mail_parts["mail_charset"] = $mail_charset;
   $mail_parts["mail_encoding"] = $mail_encoding;

   $mail_parts["userfile"] = $userfile;
   $mail_parts["userfile_type"] = $userfile_type;
   $mail_parts["userfile_name"] = $userfile_name;
   $mail_parts["userfile_size"] = $userfile_size;


   $mail_parts["mail_to"] = $mail_to;
   $mail_parts["mail_from"] = $mail_from;
   $mail_parts["mail_reply_to"] = $mail_reply_to;
   $mail_parts["mail_cc"] = $mail_cc;
   $mail_parts["mail_bcc"] = $mail_bcc;
   $mail_parts["mail_subject"] = trim($mail_subject);
   $mail_parts["mail_body"] = $mail_body;

   if(my_mail($mail_parts))
      user_message("Successfully sent an e-mail titled '$mail_subject'.");
        else error_message("An unknown error occurred while attempting to
                                 send an e-mail titled '$mail_subject'.");
}

function my_mail($mail_parts)
{
   $mail_to = $mail_parts["mail_to"];
   $mail_from = $mail_parts["mail_from"];
   $mail_reply_to = $mail_parts["mail_reply_to"];
   $mail_cc = $mail_parts["mail_cc"];
   $mail_bcc = $mail_parts["mail_bcc"];
   $mail_subject = $mail_parts["mail_subject"];
   $mail_body = $mail_parts["mail_body"];

   $mail_type = $mail_parts["mail_type"];
   $mail_charset = $mail_parts["mail_charset"];
   $mail_encoding = $mail_parts["mail_encoding"];

   $userfile = $mail_parts["userfile"];
   $userfile_type = $mail_parts["userfile_type"];
   $userfile_name = $mail_parts["userfile_name"];
   $userfile_size = $mail_parts["userfile_size"];

   if(empty($mail_to)) error_message("Empty to field!");
   if(empty($mail_subject)) error_message("Empty subject!");
   if(empty($mail_body)) error_message("Empty body! ");

   $mail_to = str_replace(";", ",", $mail_to);

   $mail_headers = '';

   if(!empty($mail_from)) $mail_headers .= "From: $mail_from\n";
   if(!empty($mail_reply_to)) $mail_headers .= "Reply-to: $mail_reply_to\n";
   if(!empty($mail_cc))
            $mail_headers .= "Cc: " . str_replace(";", ",", $mail_cc) . "\n";
   if(!empty($mail_bcc))
            $mail_headers .= "Bcc: " . str_replace(";", ",", $mail_bcc) . "\n";

   $mail_subject = stripslashes($mail_subject);
   $mail_body = stripslashes($mail_body);

   if($userfile_size > 0)
   {
      $mail_boundary = md5(uniqid(time()));
      $mail_headers .= "MIME-Version: 1.0\r\n";
      $mail_headers .= "Content-type: multipart/mixed;
                                      boundary=\"$mail_boundary\"\r\n\r\n";
      $mail_headers .= "This is a multi-part message in MIME format.\r\n\r\n";

      $fp = fopen($userfile, "r");
      $file = fread($fp, filesize($userfile));
      $file = chunk_split(base64_encode($file));

      $new_mail_body = "--$mail_boundary\r\n";
      $new_mail_body .= "Content-type:text/plain;charset=$mail_charset\r\n";
      $new_mail_body .= "Content-transfer-encoding:$mail_encoding\r\n\r\n";
      $new_mail_body .= "$mail_body\r\n";
      $new_mail_body .= "--$mail_boundary\r\n";
      if(!empty($userfile_type)) $mime_type = $userfile_type;
      else $mime_type = "application/octet-stream";

      $new_mail_body .= "Content-type:$mime_type;name=$userfile_name\r\n";
      $new_mail_body .= "Content-transfer-encoding:base64\r\n\r\n";
      $new_mail_body .= $file . "\r\n\r\n";
      $new_mail_body .= "--$mail_boundary--";
      $mail_body = $new_mail_body;
   }
   else if($mail_type == 'html')
   {
      $mail_headers .= "Content-type: text/html; charset=$mail_charset\r\n";
      $mail_headers .= "Content-transfer-encoding:$mail_encoding\r\n\r\n";
   }
   else
   {
      $mail_headers .= "Content-type: text/plain; charset=$mail_charset\r\n";
      $mail_headers .= "Content-transfer-encoding:$mail_encoding\r\n\r\n";
   }

   return mail($mail_to,$mail_subject,$mail_body,$mail_headers);
}

switch ($action)
{
   case "send_mail":
      mailer_header();
      send_mail();
      mailer_footer();
      break;
   case "mail_form":
      mailer_header();
      mail_form();
      mailer_footer();
      break;
   default:
      mailer_header();
      mail_form();
      mailer_footer();
      break;
}
?>

This post was edited on 08-26-2005 at 04:03 AM by brian.
08-26-2005 03:59 AM
Profile PM Find Quote Report
dotNorma
Veteran Member
*****

Avatar

Posts: 1745
Reputation: 17
33 / Male / –
Joined: May 2003
O.P. RE: Help with ASP; Web programming.
Sorry about the ASP part. I tried another script I was just asking about and it was coded in ASP and I just accidently said ASP over here for a different script. Its PHP :grin: Let me test one moment...
08-26-2005 12:44 PM
Profile PM Web Find Quote Report
dotNorma
Veteran Member
*****

Avatar

Posts: 1745
Reputation: 17
33 / Male / –
Joined: May 2003
O.P. RE: Help with ASP; Web programming.
Thanks alot, I got it working.

It didnt work origanilly though, your "echo" function set the data to the wrong variable. It used mailto instead of mail_to or something like that. Same with the very top declarations. But I was able to spot that.
08-26-2005 09:48 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On