Helpful Information
 
 
Category: Project Help Wanted
Need a script made for a form

Hey everyone,
For anyone who is willing to help, I need a script made for my website. Here is what is going on. I have a page that has forms for user information and an attachment. I need the info and the file from that page sent to my email address when the user clicks send. If anyone is willing to help I would be glad to add a link to there website and give them full credit for the script!
Thanks alot guys!
-Jason:)

post your html form here.we will help you on that.

<<
If anyone is willing to help I would be glad to add a link to there website and give them full credit for the script!
>>

no need for the link and all.

Thank you for helping me!
Below is the forms HTML I have, its the whole page, but all thats on it is the form stuff. I don't know the first thing about all this scripts and stuff.
Thanks again!
-Jason

<html>
<head>
<title>Welcome to Freaky Faces</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') {
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}

function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="" enctype="multipart/form-data">
<table width="55%" border="0" align="center" cellspacing="0" cellpadding="3" bordercolor="#CCCCCC">
<tr bgcolor="#CCCCCC">
<td width="38%">
<div align="right"><b>Enter your first name:</b></div>
</td>
<td width="62%">
<div align="left">
<input type="text" name="name" onBlur="MM_validateForm('name','','R');return document.MM_returnValue">
</div>
</td>
</tr>
<tr>
<td width="38%">
<div align="right"><b>Enter your e-mail:</b></div>
</td>
<td width="62%">
<div align="left">
<input type="text" name="email" onBlur="MM_validateForm('email','','RisEmail');return document.MM_returnValue">
</div>
</td>
</tr>
<tr bgcolor="#CCCCCC">
<td width="38%">
<div align="right"><b>Attach the picture you want to get distorted:</b></div>
</td>
<td width="62%" valign="middle">
<div align="left">
<input type="file" name="file">
</div>
</td>
</tr>
<tr>
<td width="38%" valign="top">
<div align="right"><b>If you want anything specific done to the file,
type it here:</b></div>
</td>
<td rowspan="2" width="62%" align="center" valign="top">
<div align="left">
<textarea name="extra" rows="8" cols="35"></textarea>
</div>
</td>
</tr>
<tr>
<td width="38%">
<div align="left"> </div>
</td>
</tr>
</table>
<div align="center">
<hr>
<input type="submit" name="send" value="Send" onClick="MM_callJS('processForm()')">
<input type="reset" name="reset" value="Reset">
</div>
</form>
</body>
</html>

Here is a php script I found someplace, this is the original, it doesn't have the creators info so I can't give credit but you should be able to find it useful. thee are 3 seperate parts
mime.class
mime.def
and an example

________________________________________________
<?php
/* ---------------------------------------------------------
MIME Class:
Allows creation of e-mail messages via the MIME Standard.
The class supports multiple attachments and presenting
an e-mail in HTML.
--------------------------------------------------------- */
include ("MIME.def");

class MIME_mail {
//public:
var $to;
var $from;
var $subject;
var $body;
var $headers = "";
var $errstr="";

// these are the names of the encoding functions, user
// provide the names of user-defined functions

var $base64_func= ''; # if !specified use PHP's base64
var $qp_func = ''; # None at this time

// If do not have a local mailer..use this array to pass info of an SMTP object
// e.g. $mime_mail->mailer = array('name' => 'smtp', method => 'smtp_send()');
// 'name' is the name of the object less the $ and 'method' can have parameters
// specific to itself. If you are using MIME_mail object's to, from, etc.
// remember to send parameters a literal strings referring 'this' object!!!!
// If in doubt, you are probably better off subclassing this class...
var $mailer = ""; # Set this to the name of a valid mail object

//private:
var $mimeparts = array();

// Constructor.
function MIME_mail($from="", $to="", $subject="", $body="", $headers = "") {
$this->to = $to;
$this->from = $from;
$this->subject = $subject;
$this->body = $body;
if (is_array($headers)) {
if (sizeof($headers)>1)
$headers=join(CRLF, $headers);
else
$headers=$headers[0];
}
if ($from) {
$headers = preg_replace("!(from:\ ?.+?[\r\n]?\b)!i", '', $headers);
}
$this->headers = chop($headers);
$this->mimeparts[] = "" ; //Bump up location 0;
$this->errstr = "";
return;
}

/* ---------------------------------------------------------
Attach a 'file' to e-mail message
Pass a file name to attach.
This function returns a success/failure code/key of current
attachment in array (+1). Read attach() below.
--------------------------------------------------------- */
function fattach($path, $description = "", $contenttype = OCTET, $encoding = BASE64, $disp = '') {
$this->errstr = "";
if (!file_exists($path)) {
$this->errstr = "File does not exist";
return 0;
}
// Read in file
$fp = fopen($path, "rb"); # (b)inary for Win compatability
if (!$fp) {
$this->errstr = "fopen() failed";
return 0; //failed
}
$contenttype .= ";\r\n\tname=".basename($path);
$data = fread($fp, filesize($path));
return $this->attach($data,
$description,
$contenttype,
$encoding,
$disp);
}

/* ---------------------------------------------------------
Attach data provided by user (rather than a file)
Useful when you want to MIME encode user input
like HTML. NOTE: This function returns key at which the requested
data is attached. IT IS CURRENT KEY VALUE + 1!!
Construct the body with MIME parts
--------------------------------------------------------- */
function attach($data, $description = "", $contenttype = OCTET, $encoding = BASE64, $disp = '') {
$this->errstr = "";
if (empty($data)) {
$this->errstr = "No data to be attached";
return 0;
}
if (trim($contenttype) == '') $contenttype = OCTET ;
if (trim($encoding) == '') $encoding = BASE64;
if ($encoding == BIT7) $emsg = $data;
elseif ($encoding == QP)
$emsg = $$this->qp_func($data);
elseif ($encoding == BASE64) {
if (!$this->base64_func) # Check if there is user-defined function
$emsg = base64_encode($data);
else
$emsg = $$this->base64_func($data);
}
$emsg = chunk_split($emsg);
//Check if content-type is text/plain and if charset is not specified append default CHARSET
if (preg_match("!^".TEXT."!i", $contenttype) && !preg_match("!;charset=!i", $contenttype))
$contenttype .= ";\r\n\tcharset=".CHARSET ;
$msg = sprintf("Content-Type: %sContent-Transfer-Encoding: %s%s%s%s",
$contenttype.CRLF,
$encoding.CRLF,
((($description) && (BODY != $description))?"Content-Description: $description".CRLF:""),
($disp?"Content-Disposition: $disp".CRLF:""),
CRLF.$emsg.CRLF);
BODY==$description? $this->mimeparts[0] = $msg: $this->mimeparts[] = $msg ;
return sizeof($this->mimeparts);
}

/* ---------------------------------------------------------
private:
Construct mail message header from info already given.
This is a very important function. It shows how exactly
the MIME message is constructed.
--------------------------------------------------------- */
function build_message() {


$this->errstr = "";
$msg = "";
$boundary = 'PM'.chr(rand(65, 91)).'------'.md5(uniqid(rand())); # Boundary marker
$nparts = sizeof($this->mimeparts);

// Case 1: Attachment list is there. Therefore MIME Message header must have multipart/mixed
if (is_array($this->mimeparts) && ($nparts > 1)):
$c_ver = "MIME-Version: 1.0".CRLF;
$c_type = 'Content-Type: multipart/mixed;'.CRLF."\tboundary=\"$boundary\"".CRLF;
$c_enc = "Content-Transfer-Encoding: ".BIT7.CRLF;
$c_desc = $c_desc?"Content-Description: $c_desc".CRLF:"";
$warning = CRLF.WARNING.CRLF.CRLF ;

// Since we are here, it means we do have attachments => body must become an attachment too.
if (!empty($this->body)) {
$this->attach($this->body, BODY, TEXT, BIT7);
}

// Now create the MIME parts of the email!
for ($i=0 ; $i < $nparts; $i++) {
if (!empty($this->mimeparts[$i]))
$msg .= CRLF.'--'.$boundary.CRLF.$this->mimeparts[$i].CRLF;
}
$msg .= '--'.$boundary.'--'.CRLF;
$msg = $c_ver.$c_type.$c_enc.$c_desc.$warning.$msg;
else:
if (!empty($this->body)) $msg .= $this->body.CRLF.CRLF;
endif;
return $msg;
}


/* ---------------------------------------------------------
public:
Now Generate the entire Mail Message, header and body et al.
--------------------------------------------------------- */
function gen_email($force=false) {

$this->errstr = "";
if (!empty($this->email) && !$force) return $this->email ; // saves processing
$email = "";
if (empty($this->subject)) $this->subject = NOSUBJECT;
if (!empty($this->from)) $email .= 'From: '.$this->from.CRLF;
if (!empty($this->headers)) $email .= $this->headers.CRLF;
$email .= $this->build_message();
$this->email = $email;
return $this->email;
}

/* ---------------------------------------------------------
public:
Printable form
--------------------------------------------------------- */
function print_mail($force=false) {
$this->errstr = "";
$email = $this->gen_email($force);
if (!empty($this->to)) $email = 'To: '.$this->to.CRLF.$email;
if (!empty($this->subject)) $email = 'Subject: '.$this->subject.CRLF.$email;
print $email;
}

/* ---------------------------------------------------------
public:
Send mail via local mailer
--------------------------------------------------------- */
function send_mail($force=false) {
$this->errstr = "";
$email = $this->gen_email($force);
if (empty($this->to)) {
$this->errstr = "To Address not specified";
return 0;
}
if (is_array($this->mailer) && (1 == sizeof($this->mailer)) ) {
$mail_obj = $this->mailer['name'];
$mail_method = $this->mailer['method'];
if (empty($mail_obj)) {
$this->errstr = "Invalid object name passed to send_mail()";
return 0;
}
global $mail_obj;
eval("$ret = \$$mail_obj".'->'."$mail_method;");
return $ret;
}
return mail($this->to, $this->subject, "", $email);
}
} // Class End
------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<?php
/* -----------------------------------------------------------
mime.def Constants used inside the class. This file is included
by the class module and these constants an be freely
used in scripts using MIME_mail class
----------------------------------------------------------- */

define('BASE64', 'base64');
define('BIT7', '7bit');
define('QP', 'quoted_printable');
define('NOSUBJECT', '(No Subject)');
define('WARNING', 'This is a MIME encoded message');
define('OCTET', 'application/octet-stream');
define('TEXT', 'text/plain');
define('HTML', 'text/html');
define('JPEG', 'image/jpg');
define('GIF', 'image/gif');
define('CRLF', "\r\n");
define('CHARSET', 'us-ascii');
define('INLINE', 'inline');
define('ATTACH', 'attachment');
define('BODY', CRLF.'BODY'.CRLF);
?>

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

the example html
----------------------------------------------------------------------

<html>
<head>
<title>Mime Example 1</title>
<style type="text/css">
input.submit {
background-color: #ffffe0;
font-weight: bold;
}
</style>
</head>
<body>
<?php
/* --------------------------------------------------
This example shows how to use the class to get an
attachment from a user and send it via email.
e.g., a job site where a prospect is sending
resume.
-------------------------------------------------- */
include "MIME.class";
define('TO', 'jobs@company.com'); # CHANGE THIS TO A REAL ADDRESS (yours?)

// Has there been a form submission? If yes, go on and
// process...
if (is_array($HTTP_POST_VARS)) {

if ($resume != 'none') {
$fname = './'.$resume_name; // make a real filename
// Get the content-type of the uploaded file

if (preg_match("!/x\-.+!i", $resume_type))
$type = OCTET;
else
$type = $resume_type;

$from = sprintf("'%s' <%s>", $name, $email) ;
copy($resume, $fname); //do error checking if need
$mime = new MIME_mail($from, TO, 'Resume', "Please find attached my resume", "Cc: $email");
$mime->fattach($fname, "Resume of $name", $type);
$mime->send_mail();
echo "Dear $name<p>Your resume has been emailed and a copy sent to you<br>";
unlink($resume); // remove the uploaded file
} else {
echo "Dear $name<p>You have not submitted your resume. Please use the browse button to attach it and click send!<br>";
}
}
?>

<form name="upload" action="<?php echo $PHP_SELF;?>" method="post" enctype="multipart/form-data">
<table cellpadding=0 cellspacing=0 summary="upload table">
<tr>
<td>Name:</td><td><input name="name" size=30 maxlength=60>
</tr>
<tr>
<td>E-mail:</td><td><input name="email" size=30 maxlength=60>
</tr>
<tr>
<td>Resume:</td><td><input type=file name="resume"></td>
</tr>
<tr>
<td colspan=2 align="right"><input type=submit class='submit' name='action' value='Send'></td>
</tr>
</table>
</form>










privacy (GDPR)