Jump to content

ScottAllenNet

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by ScottAllenNet

  1. Thanks for your help but I am still a little lost as to how best integrate that with my existing code.
  2. Thanks for that - can't seem to find much on the attaching of the file into the email that the back end sends though?
  3. Hi Guys, I am having some trouble creating a form process due to a simple lack of knowlegde. Here is my current php code: <?php $EmailFrom = "website@harrisonpearce.com"; $EmailTo = "register@harrisonpearce.com"; $Subject = "New Candidate Registration"; $name = Trim(stripslashes($_POST['name'])); $email = Trim(stripslashes($_POST['email'])); $telephone = Trim(stripslashes($_POST['telephone'])); $location = Trim(stripslashes($_POST['location'])); $attachcv = Trim(stripslashes($_POST['attachcv'])); $coveringletter = Trim(stripslashes($_POST['coveringletter'])); // validation $validationOK=true; if (Trim($name)=="") $validationOK=false; if (Trim($email)=="") $validationOK=false; if (Trim($telephone)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../../error\">"; exit; } // email body text $Body = ""; $Body .= "Name: "; $Body .= $name; $Body .= "\n"; $Body .= "Email: "; $Body .= $email; $Body .= "\n"; $Body .= "Telephone: "; $Body .= $telephone; $Body .= "\n"; $Body .= "Location: "; $Body .= $location; $Body .= "\n"; $Body .= "Attach CV: "; $Body .= $attachcv; $Body .= "\n"; $Body .= "Covering Letter: "; $Body .= $coveringletter; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../../sent\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=../../error\">"; } ?> And here is the front end HTML code: <form name="submit-cv" id="submit-cv" action="_layout/php/submit-cv.php" method="post"> <table> <tbody><tr> <td> Your Name: <font color="#DA1623">*</font><br /> <input id="name" class="text" type="text" value="" name="name"> </td> <td> Email Address: <font color="#DA1623">*</font><br /> <input id="email" class="text" type="text" value="" name="email"> </td> </tr> <tr> <td> Telephone: <font color="#DA1623">*</font><br /> <input id="telephone" class="text" type="text" value="" name="telephone"> </td> <td> Location:<br /> <input id="location" class="text" type="text" value="" name="location"> </td> </tr> <tr> <td colspan="2"> Attach CV:<br /> <input type="file" name="attachcv" id="attachcv" /> </td> </tr> <tr> <td colspan="2"> Covering Letter:<br /> <textarea name="coveringletter" rows="5" cols="20"></textarea> </td> </tr> </tbody></table> <input type="submit" name="submit" value="Send Details"> </form> At the moment, as you can see the attach CV field is a simple text entry field - I want to make this a file upload field which will then attach the file to the email that it sends to me. Any assistance in this would be fantastic. Best, Scott.
  4. Many, many thanks guys. Really appreciated - been a thorn in my side. Scott.
  5. Hi Guys, PHP has never been my fortay and I have hit a real snag. Please find below code for a simple PHP contact form. However, in the subject line of the email sent to me I would like it to show: Contact Form: $subject - ($subject is what is currently displayed). I know this is a simple fix however I have been messing about for hours and can't seem to get it right. Any help would be greatly appreciated. Best, Scott. <?php define("WEBMASTER_EMAIL", 'contact@pearceresourcing.com'); error_reporting (E_ALL ^ E_NOTICE); ////////////////////////////////////////////////////// function ValidateEmail($email) { $regex = '/([a-z0-9_.-]+)'. # name '@'. # at '([a-z0-9.-]+){2,255}'. # domain & possibly subdomains '.'. # period '([a-z]+){2,10}/i'; # domain extension if($email == '') return false; else $eregi = preg_replace($regex, '', $email); return empty($eregi) ? true : false; } ////////////////////////////////////////////////////// $post = (!empty($_POST)) ? true : false; if($post) { $name = stripslashes($_POST['name']); $email = trim($_POST['email']); $subject = trim($_POST['subject']); $message = stripslashes($_POST['message']); $error = ''; // Check name if(!$name) $error .= 'Name required! '; // Check email if(!$email) $error .= 'E-mail required! '; if($email && !ValidateEmail($email)) $error .= 'E-mail address is not valid! '; // Check message if(!$message) $error .= "Please enter your message!"; if(!$error) { $mail = mail(WEBMASTER_EMAIL, $subject, $message, "From: ".$name." <".$email.">\r\n" ."Reply-To: ".$email."\r\n" ."X-Mailer: PHP/" . phpversion()); if($mail) echo 'OK'; } else echo '<div class="errormsg">'.$error.'</div>'; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.