Hi All,
I am new to the boards and I've been working on a form (which is rather massive, imo) and i've been looking online at other peoples php examples for multipart emails. The code i am using / editing (trying to learn and understand it) is one of the web examples I found..... I have some questions:
1) onSubmit my action attribute is calling <someReuest.php>, is this a good idea? I assume yes.
Code: <form id="1" enctype="multipart/form-data" name="siteRequest" onSubmit="return validate()" method="post" action="someReuest.php">
2) in my php file i'm creating a new variable for each form field (before beinging to process anything)
e.g. $headerimage = $_POST['headerimage']; where header image is the name of one of my form fields. Is this a good practice or is this an unnecessary step?
3) I have 10 form fields of type=file thus do I need to loop over my mail attachment function? see below. Again, this function was found on the internet which i'm trying to edit, work with, learn, etc..
I know using someone else code isn't a good idea, but i'm trying to learn, and multipart isn't the easiest thing for a newb to learn.
function mail_attachment ($from , $to, $subject, $message, $attachment) {
//posting attachment to mail
$fileatt = $attachment; //path to file
$fileatt_type = "image/jpeg"; //filetype
$start = strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1;
$fileatt_name = substr($attachment, $start, strlen($attachment)); //file name used for attachment
$email_from = $from; //who e-mail is from
$email_subject = $subject; //subject of e-mail
$email_txt = $message; //message that the emal has in it
$email_to = $to; //who the email is to
$headers = "From: ".$email_from;
if(!($file = fopen($fileatt,'rb'))) echo "Failed To Open File $fileatt"; //read binary bytes
$data = fread($file,filesize($fileatt));
fclose($file);
$msg_txt="nn There is an attachment with this request, please review. The message came from: $from";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x($semi_rand)x";
$headers .= "nMIME-Version: 1.0n" .
"Content-Type: multipart/mixed;n" .
" boundary="{$mime_boundary}"";
$email_txt .= $msg_txt;
$email_message .= "This is a multipart message in MIME format.nn" .
"--{$mime_boundary}n" .
"Content-Type:text/html; charset="iso-8859-1"n" .
"Content-Transfer-Encoding: 7bitnn" .
$email_txt . "nn";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}n" .
"Content-Type: {$fileatt_type};n" .
" name="{$fileatt_name}"n" .
//"Content-Disposition: attachment;n" .
//" filename="{$fileatt_name}"n" .
"Content-Transfer-Encoding: base64nn" .
$data . "nn" .
"--{$mime_boundary}--n";
$ok = mail($email_to, $email_subject, $email_message, $headers);
if($ok)
{
echo "File Sent Successfully.";
unlink($attachment); //delete file off server after its attached
}
else
{
die("Sorry the email could not be sent.");
}
}
This is a good start I know there will be more, but i'll try to use the helpful suggestions for these first 3 questions first.
Sorry if there isn't enough code here, let me know if more needs to be added
limitations on array_unique()
Does any one know what/how imitations are applied to array_unique? I have an issue where no matter how big (as in over this limit) the array is array_unique always returns an array with 32768
DELETE rows based on content
I have a link in my rows$bit="http://bit.ly/abcd";$query = mysql_query("DELETE FROM *table* WHERE sentence........");//I need to delete all sentence rows which DOES NOT contain my
question about n
I was looking at some of the things you could do with php and one of the things I have tried is \n.used this wayCode: [Select]while(list($key, $val) = each($myArray)){ echo "$key =>
help with Get_
ok some how this is not working i am not sure what i am doing wrong here but what this does is when the user goes to Secret-Codes.php they get a menu and when they pick the phone they want to view it
string to currency format
Hi guys...Actually I chunk out some data from txtfile and one of the data contains amount value but in string format like so.."000000010000" -->desire result
How to replace search button with link?
hi to everbody.i have a search submit form and button like this :<form id="f1" name="title" method="post"
Install page
How do I make it so when a user submits information on the Install page, it'll right it into the correct file. I can do the forms and $_POST, but I need it so that it actually works.Current stuff in
Help! refer to a friend script with captcha code
Hi guys, I am posting on here in desperate need for some help with an ongoing search I have been doing for the last few weeks. Basically I have searched the web, high and low for a "mail to a
Passing PHP variables from one page to another
Hello-I'm having trouble figuring out how to transport a variable from one php file to another. Specifically, the name of an image, to be used as a subject in a form mail. I don't even really have the
Revoking alter any table from a schema
Hi All,