Jump to content

BlowYourMind

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by BlowYourMind

  1. Thanks, when I filled in the correct pw but incorrect username, it still directed to the password protected page, so you were right :PI've changed the password and username check, changed it to this: <?phpif($_POST["usern"] != "admin" or $_POST["pass"] != "admin") {echo "Gebruikersnaam en/of wachtwoord verkeerd ingevoerd!<br>"; }else { ?> Now it only directs to the protected page when the username and password is correct (: Also, logging on is done on the index.php page: <div id="logon" align="left" style="float:left;"> <form action="pass.php" method="post" id="inlogding"> Gebruikersnaam: <input name="usern" type="text" value="" size="9"><br /> Wachtwoord:   <input name="pass" type="password" value="" size="9" style="margin-left:1px;"><br /> <input type="submit" value="Log in"> </form></div> And about validating: Did you mean I should put "$dir = 'uploads/foto/'.$_POST['cat'].'/'" in my code? Because that line is already there..
  2. Hi everyone! I'm trying to get one of my pages password protected: It's a page where I upload my new photos for my portfolio.So to prevent anyone deleting or adding photo's, I want to password protect this page. I've followed a tutorial online (I think it's this one: http://www.wysiwygwebbuilder.com/password_protect.html) and my page IS protected by password and username, but when I try to delete a photo, or add one, I get an error that my password and username are incorrect. This is the site on which I'm working: http://imandra.woelmuis.nl/(It has only one page for normal viewers, containing all the content, shown by jQuery)With the settingsicon at the top right you can log on, and that's working properly. The page to which you are sent to when logging on: <?php if($_POST["usern"] != "admin") {echo "Gebruikersnaam verkeerd ingevoerd!<br>"; }if($_POST["pass"] != "admin"){echo "Wachtwoord verkeerd ingevoerd!";}else { ?> <?phpif (isset($_GET['delete'])){ unlink($_GET['delete']); header('location:'.$_SERVER['PHP_SELF']);die;}include 'fotocat.php';ini_set ("display_errors", "1");error_reporting(E_ALL);if (isset($_POST['upload_submit']))//upload submit is de submit knop dus deze check kan anders en deze code ook op andere pagina indien je niet naar jezelf wil posten{ include 'core/class/image.php';//class met aantal image resize functies let op deze is niet zo geweldig maar mogelijk wel nuttig/te gebruiken/bewerken $dir = 'uploads/foto/'.$_POST['cat'].'/';//maak hier ook maar van wat je wilt \\ voor windows / voor andere systemen met mappen vergeet niet de slash op het einde if (!is_dir($dir)) mkdir($dir); //afbeelding word zo verkleind dat de smalste kant (x of y) 50 px breed of hoog is, dan word van de lange kant het overtollige afgesneden zodat er 50x50 overblijft $thumbX = 50;//thumb breedte $thumbY = 50;//thumb hoogte //dit zijn de grenzen van de te uploaden afbeelding, stel je hebt een afbeelding van 1200x600 word deze 800x400 na uploaden en 1024x768 word gewoon 800x600 //vrij in te stellen uiteraard. $imgX = 800;//afb word geresized naar 800 breed $imgY = 800;//afb word geresized naar 600 breed foreach($_FILES as $img) { if (!empty($img['name']))//bestand is dus geupload er is een naam beschikbaar { $randomname = date('dmy').rand(1,9999);//timestamp als naam $oldname = $img['name']; $ext = File::getExtension($oldname); //eerst geheel uploaden $upload = File::upload($img['tmp_name'],$dir.$randomname.'.'.$ext); //resizen naar een degelijk formaat $image = Image::resize($dir.$randomname.'.'.$ext, $randomname.'.'.$ext, $dir, array( array('width' => $imgX, 'height' => $imgY) )); //thumbnail maken $thumb = Image::cropImage($dir.$randomname.'.'.$ext, $thumbX, $thumbY); if (File::getExtension($oldname) == 'png') imagepng($thumb, $dir.$randomname.'_thumb.'.File::getExtension($oldname)); elseif(File::getExtension($oldname) == 'jpg' || File::getExtension($oldname) == 'jpeg') imagejpeg($thumb,$dir.$randomname.'_thumb.'.File::getExtension($oldname)); imagedestroy($thumb); } } header('location:'.$_SERVER['PHP_SELF']);die;//het is aan te raden de pagina geforceerd te refreshen (anders heb je op F5 dezelfde foto nogmaals geupload}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel = "stylesheet" type="text/css" href="style1.css"> <script type="text/javascript" src="lib/js/jquery.js"></script> <script type="text/javascript"> </script> </head> <body> <div> <div id="uploadzooi"> <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> <p class="titel">Categorie: </p><select name="cat"> <?php foreach($fotocat as $key => $value) { print '<option value="'.str_replace(' ','_',$key).'">'.$key.'</option>'; } ?> </select><br /><br /> Bestand:<br /><input type="file" name="img" style="width:100px"/><br /><br /> Bestand:<br /><input type="file" name="img2" style="width:100px"/><br /><br /> Bestand:<br /><input type="file" name="img3" style="width:100px"/><br /><br /> Bestand:<br /><input type="file" name="img4" style="width:100px"/><br /><br /> Bestand:<br /><input type="file" name="img5" style="width:100px"/><br /><br /> Bestand:<br /><input type="file" name="img6" style="width:100px"/><br /><br /> Bestand:<br /><input type="file" name="img7" style="width:100px"/><br /><br /> Bestand:<br /><input type="file" name="img8" style="width:100px"/><br /><br /> Bestand:<br /><input type="file" name="img9" style="width:100px"/><br /><br /> Bestand:<br /><input type="file" name="img0" style="width:100px"/><br /><br /> <input type="submit" value="Upload" name="upload_submit" /> </form> </div> <div class="lijsten"> <ul> <?php echo '<p class="titel">Paarden</p>'; printFotos('PAARDEN',true); ?> </ul> </div> <div class="lijsten"> <ul> <?php echo '<p class="titel">Honden</p>'; printFotos('HONDEN',true); ?> </ul> </div> <div class="lijsten"> <ul> <?php echo '<p class="titel">Mensen</p>'; printFotos('MENSEN',true); ?> </ul> </div> <div class="lijsten"> <ul> <?php echo '<p class="titel">Eigen werk</p>'; printFotos('EIGEN WERK',true); ?> </ul> </div> <div class="einde"></div> </div> </body></html> <?php } ?> I'm a beginner regarding to PHP: A friend of mine made the uploadscript. So when you have a solution, please explain in very, very simple words, haha Thanks in advance! fotocat.php index.php pass.php core.zip script.js.zip
  3. Print out? Like printing as in ink on a piece of paper? Sorry, haha, feel really dumb right now . Really don't know about php: my lessons about php don't start untill next year. But, boundary and attachement don't have functions, right? <?php $sHeader = ''; // Message headers $sBody_html = ''; // HTML body message $sBody_txt = ''; // Plain text body message $aFile = ''; // files $sBoundaryId = md5(time()); // Unique boundary $sAttachment = ''; // Filedata //////////////////////////////////////////////////////////////// // @Func: AddFile // @Input: sSource // @Ouput: true or False, $this->sAttachment // @Desc: This function adds files to a email //////////////////////////////////////////////////////////////// function addFile($sSource) {global $aFile; if(file_exists($sSource)) { $fp = fopen($sSource, "rb"); $sFiledata = fread($fp, filesize($sSource)); $sFiledata = chunk_split(base64_encode($sFiledata)); fclose($fp); $sFileName = substr(strrchr($sSource, "/"), 1);if (!is_array($aFile))$aFile = array(); $aFile[$sFileName] = $sFiledata;$sAttachment = ''; foreach($aFile AS $sFileName => $sFileData){$sAttachment .= "\r\n--".$sBoundaryId."\r\n" . "Content-Type: application/octet-stream; name=\"".$sFileName."\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-Disposition: attachment; filename=\"".$sFileName."\"\r\n\r\n" . $sFileData."\r\n\r\n" . "--".$sBoundaryId."--"; } return $sAttachment; } return false; } //////////////////////////////////////////////////////////////// // @Func: setHeaders // @Input: sFrom_name, sFrom_email, iPriority, bHtml // @Ouput: none // @Desc: This function is to set the headers of the email // Also this function is auto started from the sendMail function //////////////////////////////////////////////////////////////// function setHeaders($sFrom_name, $sFrom_email, $iPriority, $bHtml) {global $aFile; $header = "From: ".$sFrom_email."\r\n" . "Reply-To: ".$sFrom_email."\r\n" . "X-Mailer: PHP/" . phpversion() . "MIME-Version: 1.0\r\n" . "Content-type:text/".($bHtml ? 'html' : 'plain')."; charset=iso-8859-1\r\n" . "Content-Type: multipart/mixed; boundary=\"".$sBoundaryId."\"\r\n\r\n"; if(is_array($aFile)) { $header .= "This is a multi-part message in MIME format.\r\n". "--".$sBoundaryId."\r\n". "Content-Transfer-Encoding: 7bit\r\n\r\n". $sAttachment;} return $header; } //////////////////////////////////////////////////////////////// // @Func: addBody // @Input: sMessage // @Ouput: none // @Desc: This function is to add the body to the email // also the attachment is included here //////////////////////////////////////////////////////////////// function addBody($sMessage) { $sMessage .= $sAttachment; $sBody_html = $sMessage; $sBody_txt = strip_tags($sMessage); } //////////////////////////////////////////////////////////////// // @Func: sendMail // @Input: sFrom_name, sFrom_mail, sSubject, sTo_name, sTo_mail, iPriority, bHtml // @Ouput: none // @Desc: In this function the email is actualy send with all the // information collected in the previous functions //////////////////////////////////////////////////////////////// function sendMail($sFrom_name, $sFrom_mail, $sSubject, $sTo_name, $sTo_mail, $ssMessage, $fFile, $iPriority = 1, $bHtml = false) { $header = setHeaders($sFrom_name, $sFrom_mail, 1, false); try {$fFile.= $ssMessage;$sSendMail = mail($sTo_name.'<'.$sTo_mail.'>', $sSubject, $ssMessage, $header); if(!$sSendMail) { throw new error(4, 'Mail could not be send'); return false; } return true; } catch(error $e) {} } ?>
  4. Exactly how do I make the boundaryID and Attachement variables global? And I changed the setHeaders function the way you said, and switched $sSendMail = mail($sTo_name.'<'.$sTo_mail.'>', $sSubject, $fFile, $header); to $sSendMail = mail($sTo_name.'<'.$sTo_mail.'>', $sSubject, $ssMessage, $header);Within the sendmail function (because the ssMessage was already in the other lines) Am I doing this right? Sorry 'bout asking so much, I really don't know PHP, haha Edit: Just tested the code so far, I still get this part: This is a multi-part message in MIME format.--Content-Transfer-Encoding: 7bitBut no random letters and numbers. But also no attachement (and still the screenfilterwarning)
  5. Thanks! The mail gets a whole lot faster in my inbox, but the attachement isn't attached to the mail, instead I get this in front of the form details: "This is a multi-part message in MIME format.--Content-Transfer-Encoding: 7bit--Content-Type: application/octet-stream; name="MSN_NadienFemLies.jpg"Content-Transfer-Encoding: base64Content-Disposition: attachment; filename="MSN_NadienFemLies.jpg" "And beneath that a whole lot of seemingly random letters and numbers. So unfortunately, all the issues remain...I probably did something wrong, here the codes I have now:(only the altered file) <?php $sHeader = ''; // Message headers $sBody_html = ''; // HTML body message $sBody_txt = ''; // Plain text body message $aFile = ''; // files $sBoundaryId = md5(time()); // Unique boundary $sAttachment = ''; // Filedata //////////////////////////////////////////////////////////////// // @Func: AddFile // @Input: sSource // @Ouput: true or False, $this->sAttachment // @Desc: This function adds files to a email //////////////////////////////////////////////////////////////// function addFile($sSource) {global $aFile; if(file_exists($sSource)) { $fp = fopen($sSource, "rb"); $sFiledata = fread($fp, filesize($sSource)); $sFiledata = chunk_split(base64_encode($sFiledata)); fclose($fp); $sFileName = substr(strrchr($sSource, "/"), 1);if (!is_array($aFile))$aFile = array(); $aFile[$sFileName] = $sFiledata;$sAttachment = ''; foreach($aFile AS $sFileName => $sFileData){$sAttachment .= "\r\n--".$sBoundaryId."\r\n" . "Content-Type: application/octet-stream; name=\"".$sFileName."\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-Disposition: attachment; filename=\"".$sFileName."\"\r\n\r\n" . $sFileData."\r\n\r\n" . "--".$sBoundaryId."--"; } return $sAttachment; } return false; } //////////////////////////////////////////////////////////////// // @Func: setHeaders // @Input: sFrom_name, sFrom_email, iPriority, bHtml // @Ouput: none // @Desc: This function is to set the headers of the email // Also this function is auto started from the sendMail function //////////////////////////////////////////////////////////////// function setHeaders($sFrom_name, $sFrom_email, $iPriority, $bHtml) {global $aFile; $header = "From: ".$sFrom_email."\r\n" . "Reply-To: ".$sFrom_email."\r\n" . "X-Mailer: PHP/" . phpversion() . "MIME-Version: 1.0\r\n" . "Content-type:text/".($bHtml ? 'html' : 'plain')."; charset=iso-8859-1\r\n" . "Content-Type: multipart/mixed; boundary=\"".$sBoundaryId."\"\r\n\r\n"; if(is_array($aFile)) { $header .= "This is a multi-part message in MIME format.\r\n" . "--".$sBoundaryId."\r\n" . "Content-Transfer-Encoding: 7bit\r\n\r\n"; } return $header; } //////////////////////////////////////////////////////////////// // @Func: addBody // @Input: sMessage // @Ouput: none // @Desc: This function is to add the body to the email // also the attachment is included here //////////////////////////////////////////////////////////////// function addBody($sMessage) { $sMessage .= $sAttachment; $sBody_html = $sMessage; $sBody_txt = strip_tags($sMessage); } //////////////////////////////////////////////////////////////// // @Func: sendMail // @Input: sFrom_name, sFrom_mail, sSubject, sTo_name, sTo_mail, iPriority, bHtml // @Ouput: none // @Desc: In this function the email is actualy send with all the // information collected in the previous functions //////////////////////////////////////////////////////////////// function sendMail($sFrom_name, $sFrom_mail, $sSubject, $sTo_name, $sTo_mail, $ssMessage, $fFile, $iPriority = 1, $bHtml = false) { $header = setHeaders($sFrom_name, $sFrom_mail, 1, false); try {$fFile.= $ssMessage;$sSendMail = mail($sTo_name.'<'.$sTo_mail.'>', $sSubject, $fFile, $header); if(!$sSendMail) { throw new error(4, 'Mail could not be send'); return false; } return true; } catch(error $e) {} } ?>
  6. Oh okay: It was very long, that's why I didn't put it in the startpost itself HTML <!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><link rel="stylesheet" type="text/css" href="style1.css" media="screen"/><title>CONTACT</title></head> <body> <div id="wrapperc"> <div id="achtergrond"> <div id="menu"> <ul> <li><a href="index.html">HOME</a></li> <li><a href="bio.html">BIOGRAFIE</a></li> <li><a href="port.html">PORTFOLIO</a> <ul> <li id="dropdownp"><a href="paard.html">Paarden</a></li> <li id="dropdownp"><a href="ruiter.html">Paard en Ruiter</a></li> <li id="dropdownp"><a href="hond.html">Honden</a></li> <li id="dropdownp"><a href="mens.html">Mensen</a></li> <li id="dropdownp"><a href="eigen.html">Eigen Werk</a></li> </ul> </li> <li><a href="rep.html">FOTOREPORTAGES</a> <ul> <li id="dropdownf"><a href="voorwaarden.html">Voorwaarden</a></li> <li id="dropdownf"><a href="tarieven.html">Tarieven</a></li> <li id="dropdownf"><a href="bestel.html">Nabestellen</a></li> </ul> </li> <li><a href="contact.html">CONTACT</a></li> </ul> </div> <div id="content"> <div id="contenttekstc"> <p class="tekst">»» CONTACT ««</p> </div> <div id="formeen"> <table> <td><form action="contactformulier.php" METHOD="post" autocomplete="on" id="contenttekst" enctype="multipart/form-data"> <fieldset> <legend>Gegevens:</legend> <b>Voornaam:</b><br> <input type="text" name="fname" /><br /> <b>Achternaam:</b><br> <input type="text" name="lname" /><br /> <b>E-mail:</b> <br> <input type="email" name="email" autocomplete="on" /><br /> <b>Mobiel nummer:</b> <br> <input type="tel" name="usrtel" /> <br> <b>Woonplaats:</b> <br> <input type="text" name="plaats" /> </fieldset> <br> <br> <br> <fieldset> <b>Commentaar:</b> <br> <textarea name="descr" style="width: 300px; height: 144px;"></textarea> </fieldset></td> <td id="contenttekst"><fieldset> <legend>Model:</legend> <br> <select name="soortshoot"> <optgroup label="Portfolio of betaald?"> <option value="portfolio">Portfolioreportage</option> <option value="betaald">Betaalde reportage</option> </optgroup> </select> <select name="soortmodel"> <option value="paard">Paard</option> <option value="hond">Hond</option> <option value="mens">Mens</option> </select> <select name="pakket"> <option value="Pakket A">Pakket A</option> <option value="Pakket B">Pakket B</option> </select> <br> <br> <b>Naam model:</b> <br> <input type="text" name="naam" /> <br> <br> <b>Ras:</b> <br> <input type="text" name="ras" /> <br> <br> <b>Foto upload:</b> <br> <input type="file" name="uploaded_file" id="fototekst" /> <br> <br> <i>of</i> <br> <br> <b>Foto link:</b> <br> <i>Upload uw foto bij Imageshack.us, photobucket.com of tinypic.com en plaats de verkregen link hier.</i> <br> <input type="text" name="foto" /> </fieldset> <br> <br> <br> <fieldset> <br> <i>Door op de versturen te drukken gaat u automatisch akkoord met de voorwaarden zoals deze op IMANDRAphotography.com beschreven staan.</i> <br> <input type="submit" value="Versturen"> <input type="reset" name="reset" value="Wissen"/> </fieldset> </form></td> </table> </div> </div> </div> </div> </body></html> PHP file 1 <?phpif(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "imandraphotography@hotmail.com"; $email_subject = "Aanvraag fotoreportage"; function died($error) { // your error code can go here echo "Het spijt me, maar er zijn er is iets niet goed ingevuld."; echo "De fouten staan hieronder.<br /><br />"; echo $error."<br /><br />"; echo "Ga terug en verbeter de fouten.<br /><br />"; die(); } $first_name = $_POST['fname']; // required $last_name = $_POST['lname']; // required $email_from = $_POST['email']; // required $telephone = $_POST['usrtel']; // not required $city = $_POST['plaats']; // required$descr = $_POST['descr']; //Get the uploaded file information$name_of_uploaded_file = basename($_FILES['uploaded_file']['name']);//get the file extension of the file$type_of_uploaded_file = substr($name_of_uploaded_file, strrpos($name_of_uploaded_file, '.') + 1);$size_of_uploaded_file = $_FILES["uploaded_file"]["size"]/1024;//size in KBs //Settings$max_allowed_file_size = 5100; // size in KB$allowed_extensions = array("jpg", "jpeg", "gif", "bmp", "png");//Validationsif($size_of_uploaded_file > $max_allowed_file_size ){ $errors .= "\n De groote van het bestand moet minder zijn dan 5mb";}//------ Validate the file extension -----$allowed_ext = false;for($i=0; $i<sizeof($allowed_extensions); $i++){ if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0){ $allowed_ext = true; }}if(!$allowed_ext){ $errors .= "\n Het geuploade bestand is niet het juiste type.. ". " Alleen de volgende extensies zijn te uploaden: ".implode(',',$allowed_extensions);} $upload_folder = "uploads/"; //copy the temp. uploaded file to uploads folder$path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;$tmp_path = $_FILES["uploaded_file"]["tmp_name"];if(is_uploaded_file($tmp_path)){ if(!copy($tmp_path,$path_of_uploaded_file)) {$errors .= '\n Er ging wat fout met het uploaden van het bestand'; }} $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 .= 'Het email adres wat u ingegeven hebt lijkt niet te kloppen.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'De voornaam die u heeft ingegeven lijkt niet te kloppen.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'De achternaam die u heeft ingegeven lijkt niet te kloppen.<br />'; } if(!preg_match($string_exp,$city)) { $error_message .= 'De plaats die u heeft ingegeven lijkt niet te kloppen.<br />'; } $email_message = "Formulierdetails hieronder.\n\n"; $email_message .= "Voornaam: ".$first_name."\n"; $email_message .= "Achternaam: ".$last_name."\n"; $email_message .= "Email: ".$email_from."\n"; $email_message .= "Mobiel nummer: ".$telephone."\n"; $email_message .= "Plaats: ".$city."\n \n";$email_message .= "Soort shoot: ".$_POST['soortshoot']."\n";$email_message .= "Soort model: ".$_POST['soortmodel']."\n";$email_message .= "Welk pakket: ".$_POST['pakket']."\n \n";$email_message .= "Naam model: ".$_POST['naam']."\n";$email_message .= "Ras model: ".$_POST['ras']."\n";$email_message .= "Beschrijving: ".$_POST['descr']."\n";$email_message .= "Afbeelding: ".$_POST['foto']."\n"; if($error_message == ""){$headers = 'From: '.$email_from."\r\n".'Reply-To: '.$email_from."\r\n" .'X-Mailer: PHP/' . phpversion();include("nicophp.php");$fFile = addFile($path_of_uploaded_file);//addBody($email_message);sendMail($first_name.' '.$last_name, $email_from, "Aanvraag fotoreportage", "IMANDRAphotography", $email_to, $email_message, $fFile);//@mail($email_to, $email_subject, $email_message, $headers); }else{echo $error_message;}?> Bedankt voor de aanvraag van een fotoreportage. Er wordt zo spoedig mogelijk contact met u opgenomen.<br />Als u binnen twee weken nog niks terughebt, mail dan even naar imandraphotography@hotmail.com. <br /><br />Klik <a href="index.html">hier</a> om terug te keren naar IMANDRAphotography.com. <?php}?> PHP file 2 <?php $sHeader = ''; // Message headers $sBody_html = ''; // HTML body message $sBody_txt = ''; // Plain text body message $aFile = ''; // files $sBoundaryId = md5(time()); // Unique boundary $sAttachment = ''; // Filedata //////////////////////////////////////////////////////////////// // @Func: AddFile // @Input: sSource // @Ouput: true or False, $this->sAttachment // @Desc: This function adds files to a email //////////////////////////////////////////////////////////////// function addFile($sSource) { if(file_exists($sSource)) { $fp = fopen($sSource, "rb"); $sFiledata = fread($fp, filesize($sSource)); $sFiledata = chunk_split(base64_encode($sFiledata)); fclose($fp); $sFileName = substr(strrchr($sSource, "/"), 1); $aFile[$sFileName] = $sFiledata; foreach($aFile AS $sFileName => $sFileData){ $sAttachment = "\r\n--".$sBoundaryId."\r\n" . "Content-Type: application/octet-stream; name=\"".$sFileName."\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-Disposition: attachment; filename=\"".$sFileName."\"\r\n\r\n" . $sFileData."\r\n\r\n" . "--".$sBoundaryId."--"; } return $sAttachment; } return false; } //////////////////////////////////////////////////////////////// // @Func: setHeaders // @Input: sFrom_name, sFrom_email, iPriority, bHtml // @Ouput: none // @Desc: This function is to set the headers of the email // Also this function is auto started from the sendMail function //////////////////////////////////////////////////////////////// function setHeaders($sFrom_name, $sFrom_email, $iPriority, $bHtml) { $header = "From: ".$sFrom_email."\r\n" . "Reply-To: ".$sFrom_email."\r\n" . "X-Mailer: PHP/" . phpversion() . "MIME-Version: 1.0\r\n" . "Content-type:text/".($bHtml ? 'html' : 'plain')."; charset=iso-8859-1\r\n" . "Content-Type: multipart/mixed; boundary=\"".$sBoundaryId."\"\r\n\r\n"; if(is_array($aFile)) { $header .= "This is a multi-part message in MIME format.\r\n" . "--".$sBoundaryId."\r\n" . "Content-Transfer-Encoding: 7bit\r\n\r\n"; } return $header; } //////////////////////////////////////////////////////////////// // @Func: addBody // @Input: sMessage // @Ouput: none // @Desc: This function is to add the body to the email // also the attachment is included here //////////////////////////////////////////////////////////////// function addBody($sMessage) { $sMessage .= $sAttachment; $sBody_html = $sMessage; $sBody_txt = strip_tags($sMessage); } //////////////////////////////////////////////////////////////// // @Func: sendMail // @Input: sFrom_name, sFrom_mail, sSubject, sTo_name, sTo_mail, iPriority, bHtml // @Ouput: none // @Desc: In this function the email is actualy send with all the // information collected in the previous functions //////////////////////////////////////////////////////////////// function sendMail($sFrom_name, $sFrom_mail, $sSubject, $sTo_name, $sTo_mail, $ssMessage, $fFile, $iPriority = 1, $bHtml = false) { $header = setHeaders($sFrom_name, $sFrom_mail, 1, false); try {$fFile.= $ssMessage; $sSendMail = mail($sTo_name.'<'.$sTo_mail.'>', $sSubject, $ssMessage, $header); if(!$sSendMail) { throw new error(4, 'Mail could not be send'); return false; } return true; } catch(error $e) {} } ?>
  7. Hi everyone! I'm building my own website (imandraphotography.com) and I want a working form that sends me an email with the form details (containing an image that the user can upload).I've been searching some code on the internet but none of it was what I wanted. So I asked a friend if he could help me, and he came this far (see attachements). And thus far it sends me an email containing the form details, but without the uploaded photo. (The photo does appear on my server in the folder 'uploads') Also, in my hotmail inbox, I get this warning when I open a email from my website:"Dit bericht wordt niet vertrouwd door onze SmartScreen-filters." (This message isn't trusted by our smartscreen-filters) Can anybody help me with this issue? (The titles etc. are in Dutch, but since there merely titles, I guess it's not a problem?) Edit: Oh, and regarding the validation: Everytime, also when there's something wrong, it also gives the message "Bedankt voor de aanvraag van een fotoreportage. Er wordt zo spoedig mogelijk contact met u opgenomen.<br />Als u binnen twee weken nog niks terughebt, mail dan even naar imandraphotography@hotmail.com. <br /><br />Klik <a href="index.html">hier</a> om terug te keren naar IMANDRAphotography.com." (The thanks for the email, you'll soon be contacted etc part)It's no big deal, but just annoying ! contact.html contactformulier.php nicophp.php
×
×
  • Create New...