briedelis
Narys
Patrankų mėsa
Pranešimai: 6
Įstojęs: 2013 Rugs. 11 01:09:20
Sveiki, gal galit pagelbėti, dvi dienas bandau padaryti bet niekaip neišeina. Turiu contact formą, bet joje nėra funkcijos prisegti failą. HTML kodą susiradau, bet nežinau kaip papildyti php script.
Taigi, HTML kodas:
< form name= "htmlform" method= "post" action= "html_form_send.php" >
< table width= "450px" >
</ tr>
< tr>
< td valign= "top" >
< label for = "first_name" > First Name *</ label>
</ td>
< td valign= "top" >
< input type= "text" name= "first_name" maxlength= "50" size= "30" >
</ td>
</ tr>
< tr>
< td valign= "top" ">
<label for=" last_name">Last Name *</label>
</td>
<td valign=" top">
<input type=" text" name=" last_name" maxlength=" 50 " size=" 30 ">
</td>
</tr>
<tr>
<td valign=" top">
<label for=" email">Email Address *</label>
</td>
<td valign=" top">
<input type=" text" name=" email" maxlength=" 80 " size=" 30 ">
</td>
</tr>
<tr>
<td valign=" top">
<label for=" telephone">Telephone Number</label>
</td>
<td valign=" top">
<input type=" text" name=" telephone" maxlength=" 30 " size=" 30 ">
</td>
</tr>
<tr>
<td valign=" top">
<label for=" comments">Comments *</label>
</td>
<td valign=" top">
<textarea name=" comments" maxlength=" 1000 " cols=" 25 " rows=" 6 "></textarea>
</td>
</tr>
<tr>
<td colspan=" 2 " style=" text- align: center">
<input type=" submit" value=" Submit">
</td>
</tr>
</table>
</form>
php script kodas:
<?php
if ( isset ( $_POST [ 'email' ] ) ) {
// CHANGE THE TWO LINES BELOW
$email_to = "email@email.com" ;
$email_subject = "subject" ;
function died( $error ) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. " ;
echo "These errors appear below.<br /><br />" ;
echo $error . "<br /><br />" ;
echo "Please go back and fix these errors.<br /><br />" ;
die ( ) ;
}
// validation expected data exists
if ( ! isset ( $_POST [ 'first_name' ] ) ||
! isset ( $_POST [ 'last_name' ] ) ||
! isset ( $_POST [ 'email' ] ) ||
! isset ( $_POST [ 'telephone' ] ) ||
! isset ( $_POST [ 'comments' ] ) ) {
died( 'We are sorry, but there appears to be a problem with the form you submitted.' ) ;
}
$first_name = $_POST [ 'first_name' ] ; // required
$last_name = $_POST [ 'last_name' ] ; // required
$email_from = $_POST [ 'email' ] ; // required
$telephone = $_POST [ 'telephone' ] ; // not required
$comments = $_POST [ 'comments' ] ; // required
$error_message = "" ;
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/' ;
if ( ! preg_match ( $email_exp , $email_from ) ) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />' ;
}
$string_exp = "/^[A-Za-z .'-]+$/" ;
if ( ! preg_match ( $string_exp , $first_name ) ) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />' ;
}
if ( ! preg_match ( $string_exp , $last_name ) ) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />' ;
}
if ( strlen ( $comments ) < 2 ) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />' ;
}
if ( strlen ( $error_message ) > 0 ) {
died( $error_message ) ;
}
$email_message = "Form details below.\n \n " ;
function clean_string( $string ) {
$bad = array ( "content-type" , "bcc:" , "to:" , "cc:" , "href" ) ;
return str_replace ( $bad , "" , $string ) ;
}
$email_message .= "First Name: " . clean_string( $first_name ) . "\n " ;
$email_message .= "Last Name: " . clean_string( $last_name ) . "\n " ;
$email_message .= "Email: " . clean_string( $email_from ) . "\n " ;
$email_message .= "Telephone: " . clean_string( $telephone ) . "\n " ;
$email_message .= "Comments: " . clean_string( $comments ) . "\n " ;
// create email headers
$headers = 'From: ' . $email_from . "\r \n " .
'Reply-To: ' . $email_from . "\r \n " .
'X-Mailer: <span style="border-bottom: 1px dotted black;">PHP</span>/' . phpversion ( ) ;
@ mail ( $email_to , $email_subject , $email_message , $headers ) ;
?>
<!-- place your own success <span style="border-bottom: 1px dotted black;">html</span> below -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
die ( ) ;
?>
Pridedu aš į HTML kodą, file attach kodą, o ką pridėti php scripte niekur nerandu
< form action= "index.php" enctype= "multipart/form-data" >
Select a file to upload: < input type= "file" name= "selectedfile" />
</ form>
Žmogus
Narys
Viršesnis už Dievą
Pranešimai: 5621
Įstojęs: 2006 Gru. 8 17:12:08
Siūlyčiau naudot kokia nors biblioteką email siuntimo, nes nelabai teko susidurti su paprastu php mail, kad veiktu prisėgimai
https://www.google.lt/?gws_rd=ss...p;safe=off
briedelis
Narys
Patrankų mėsa
Pranešimai: 6
Įstojęs: 2013 Rugs. 11 01:09:20
Aš radau kodą kuris, veikia 100% bet man jis netinkamas, kadangi mano žinios nėra labai stiprios, tai jį persiredaguoti kaip man reikia nelabai išeina, nes jame reikia įrašyti kokiam email siųsti žinutę, o man reikia, kad jau būtų nurodytas email automatiškai, kokį esu įrašęs HTML kode. Meginau iš šio kodo persikelti ta attach funkciją, bet ji tada neveikia. Štai tas kodas:
HTML :
< html xmlns= "http://www.w3.org/1999/xhtml" >
< head>
< meta http- equiv= "Content-Type" content= "text/html; charset=utf-8" />
< title> Email Attachment Without Upload - Excellent Web World</ title>
< style>
body{ font- family: Arial, Helvetica, sans- serif; font- size: 13px; }
th{ background: #999999; text-align:right; vertical-align:top;}
input{ width: 181px; }
</ style>
</ head>
< body>
< form action= "emailSend.php" method= "post" name= "mainform" enctype= "multipart/form-data" >
< table width= "500" border= "0" cellpadding= "5" cellspacing= "5" >
< tr>
< th> Your Name</ th>
< td>< input name= "fieldFormName" type= "text" ></ td>
</ tr>
< tr>
< tr>
< th> Your Email</ th>
< td>< input name= "fieldFormEmail" type= "text" ></ td>
</ tr>
< tr>
< th> To Email</ th>
< td>< input name= "toEmail" type= "text" ></ td>
</ tr>
< tr>
< th> Subject</ th>
< td>< input name= "fieldSubject" type= "text" id= "fieldSubject" ></ td>
</ tr>
< tr>
< th> Comments</ th>
< td>< textarea name= "fieldDescription" cols= "20" rows= "4" id= "fieldDescription" ></ textarea></ td>
</ tr>
< tr>
< th> Attach Your File</ th>
< td>< input name= "attachment" type= "file" ></ td>
</ tr>
< tr>
< td colspan= "2" style= "text-align:center;" >< input type= "submit" name= "Submit" value= "Send" >< input type= "reset" name= "Reset" value= "Reset" ></ td>
</ tr>
</ table>
</ form>
</ body>
</ html>
PHP :
<?php
$to = $_POST [ 'toEmail' ] ;
$fromEmail = $_POST [ 'fieldFormEmail' ] ;
$fromName = $_POST [ 'fieldFormName' ] ;
$subject = $_POST [ 'fieldSubject' ] ;
$message = $_POST [ 'fieldDescription' ] ;
/* GET File Variables */
$tmpName = $_FILES [ 'attachment' ] [ 'tmp_name' ] ;
$fileType = $_FILES [ 'attachment' ] [ 'type' ] ;
$fileName = $_FILES [ 'attachment' ] [ 'name' ] ;
/* Start of headers */
$headers = "From: $fromName " ;
if ( file ( $tmpName ) ) {
/* Reading file ('rb' = read binary) */
$file = fopen ( $tmpName , 'rb' ) ;
$data = fread ( $file , filesize ( $tmpName ) ) ;
fclose ( $file ) ;
/* a boundary string */
$randomVal = md5 ( time ( ) ) ;
$mimeBoundary = "==Multipart_Boundary_x{$randomVal} x" ;
/* Header for File Attachment */
$headers .= "\n MIME-Version: 1.0\n " ;
$headers .= "Content-Type: multipart/mixed;\n " ;
$headers .= " boundary=\" {$mimeBoundary} \" " ;
/* Multipart Boundary above message */
$message = "This is a multi-part message in MIME format.\n \n " .
"--{$mimeBoundary} \n " .
"Content-Type: text/plain; charset=\" iso-8859-1\" \n " .
"Content-Transfer-Encoding: 7bit\n \n " .
$message . "\n \n " ;
/* Encoding file data */
$data = chunk_split ( base64_encode ( $data ) ) ;
/* Adding attchment-file to message*/
$message .= "--{$mimeBoundary} \n " .
"Content-Type: {$fileType} ;\n " .
" name=\" {$fileName} \" \n " .
"Content-Transfer-Encoding: base64\n \n " .
$data . "\n \n " .
"--{$mimeBoundary} --\n " ;
Gal turite kokių minčių?
Žmogus
Narys
Viršesnis už Dievą
Pranešimai: 5621
Įstojęs: 2006 Gru. 8 17:12:08
Nu tai, kur $to = $_POST['toEmail']; nurodai savo emailą $to = 'emailas@emailas.emailas';
O html faile ištrini ta eilutę:
< tr>
< th> To Email</ th>
< td>< input name= "toEmail" type= "text" ></ td>
</ tr>
briedelis
Narys
Patrankų mėsa
Pranešimai: 6
Įstojęs: 2013 Rugs. 11 01:09:20
Ieškau žmogaus galinčio į pirmąjį kodą įdėti attach funkciją iš antrojo. Sumokėsiu 20LT
Dar kartelį kodai:
1 kodas:
http://www.freecontactform.com/h...
2 kodas:
http://www.excellentwebworld.com...using-php/
briedelis
Narys
Patrankų mėsa
Pranešimai: 6
Įstojęs: 2013 Rugs. 11 01:09:20
-------------------up----------------------
Peršokti į forumą:
Nebeegzistuojančios svetainės
Žaliems
Bendri PHP-F klausimai
WordPress
Kiti PHP, HTML, MySQL klausimai
Expert PHP, MySQL klausimai
Kitos TVS
C#, Python, Java, JS, C++ klausimai
Naujų modų pristatymai
Mods, Panels & Infusions
Themes
Jūsų saitai
Dalinuosi, dovanoju!
Klausimai apie domenus ir hostingus
VPS/DS serverių konfigūravimas ir valdymas
Viskas apie skaitliukus, top'us ir lankomumą
Dizaino konkursai
Parduodu - perku dizainą, banerį
Parduodu - perku - keičiuosi reklama
Parduodu - perku domeną, tinklapį
Siūlau - ieškau hostingo/VPS serverio
Parduodu - perku skriptą, modifikaciją, tvs
Socialiniai tinklai - Facebook ir kiti
Legalus verslas, teisiniai klausimai
Visa kita kas susiję su darbu ir pinigais
LTStartups.com - Lietuvos startuolių bendruomenė
Off-Topic diskusijos
IT naujienos
Portalo informacija
Narių pasiūlymai
Geležis ir programinė įranga
Grafika
Out Of Place
Su e-verslu nesusijęs darbas ir prekyba
Dalinuosi, dovanoju!