Jump to content

lander

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

lander's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. When I saw that part of the code I thought it was doing something like that because I started seeing is_uploaded_file, fopen, fread, etc. But you see, the form and the code that validates it is being generated by RapidWeaver. I never chose the option or added any fields where I would allow the users to upload files so I guess there is no point of having that part of the code in there right? I am now wondering how it actually got in there?
  2. Question... Is that part of the code indicating that I am allowing users to upload a file? $headers="From: $from\n";if (file_exists($tmp_name)){
  3. Yes I've been reading. And thanks thesaleboat! Your code fixed the second error not the first. When I hit submit I get the page with the errors and then get redirected to the contact form only this time I can see the thank you message.
  4. Hi, We have created a contact form using RapidWeaver and we keep getting this same error. Any ideas of what might be causing this? Notice: Undefined variable: tmp_name in c:\domains\designsensepanama.com\wwwroot\sourcefiles\mailer.php on line 25 Warning: Cannot modify header information - headers already sent by (output started at c:\domains\designsensepanama.com\wwwroot\sourcefiles\mailer.php:25) in c:\domains\designsensepanama.com\wwwroot\sourcefiles\mailer.php on line 58 We have our whole site pretty much ready to go, but cant figure out the above error. Out contact form works, but instead of reloading the page with “thank-you your mail has been sent” we get a blank page with the above error. The email does get sent though. our code: <?php if(!array_key_exists('formMessage', $_SESSION)) $_SESSION['formMessage'] = ""; if(!array_key_exists('form_element0', $_SESSION)) $_SESSION['form_element0'] = ""; if(!array_key_exists('form_element1', $_SESSION)) $_SESSION['form_element1'] = ""; if(!array_key_exists('form_element2', $_SESSION)) $_SESSION['form_element2'] = ""; if(!array_key_exists('form_element3', $_SESSION)) $_SESSION['form_element3'] = ""; ?> <div class="message-text"> <?php if (!$_SESSION['formMessage']) { echo 'Fill in the form below to send us an email.'; } else { echo $_SESSION['formMessage']; } ?> </div> <br /> <form action="sourcefiles/mailer.php" method="post" enctype="multipart/form-data"> <label>Your Name:</label> * <br /> <input class="form-input-field" type="text" value="<?php echo $_SESSION['form_element0']; ?>" name="form_element0" size="40" /> <br /> <br /> <label>Your Email:</label> * <br /> <input class="form-input-field" type="text" value="<?php echo $_SESSION['form_element1']; ?>" name="form_element1" size="40" /> <br /> <br /> <label>Subject:</label> * <br /> <select name="form_element2"> <option <?php if ($_SESSION['form_element2'] == "I am interested in a new web presence") { echo "selected"; } ?> value="I am interested in a new web presence"> I am interested in a new web presence </option> <option <?php if ($_SESSION['form_element2'] == "I am interested in a re-design of my existing site.") { echo "selected"; } ?> value= "I am interested in a re-design of my existing site."> I am interested in a re-design of my existing site. </option> <option <?php if ($_SESSION['form_element2'] == "I am interested in website management") { echo "selected"; } ?> value="I am interested in website management"> I am interested in website management </option> <option <?php if ($_SESSION['form_element2'] == "I am interested in website marketing") { echo "selected"; } ?> value="I am interested in website marketing"> I am interested in website marketing </option> </select> <br /> <br /> <label>Message:</label> * <br /> <textarea class="form-input-field" name="form_element3" rows="8" cols="38"> <?php echo $_SESSION['form_element3']; ?> </textarea> <br /> <br /> <input class="form-input-button" type="reset" name="resetButton" value="Reset" /> <input class="form-input-button" type="submit" name="submitButton" value="Submit" /> </form> <?php session_destroy(); ?> And our mailer.php code <?php session_start(); $_SESSION['form_element0'] = $_POST['form_element0']; $_SESSION['form_element1'] = $_POST['form_element1']; $_SESSION['form_element2'] = $_POST['form_element2']; $_SESSION['form_element3'] = $_POST['form_element3']; $form_element0 = $_SESSION['form_element0']; $form_element1 = preg_replace("/\r/", "", $_SESSION['form_element1']); $form_element1 = preg_replace("/\n/", "", $form_element1); $form_element2 = preg_replace("/\r/", "", $_SESSION['form_element2']); $form_element2 = preg_replace("/\n/", "", $form_element2); $form_element3 = $_SESSION['form_element3']; if(!$_SESSION['form_element0'] || !$_SESSION['form_element1'] || !$_SESSION['form_element2'] || !$_SESSION['form_element3']) { $_SESSION['formMessage'] = " Please fill out all the required fields<br />Fields marked with * are required.\n"; Header("Location: contactus.php"); exit(); } else { $email="our e-mail address is here"; if (!eregi ("^([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,4}$", $email)) { unset($email); } $from = stripslashes($form_element0)." <".stripslashes($form_element1).">";$subject= $form_element2;$message = "\nYour Name: $form_element0\n\nYour Email: $form_element1\n\nSubject: $form_element2\n\nMessage: $form_element3\n"; $headers="From: $from\n";if (file_exists($tmp_name)){ if(is_uploaded_file($tmp_name)){ $file = fopen($tmp_name,'rb'); $data = fread($file,filesize($tmp_name)); fclose($file); $data = chunk_split(base64_encode($data)); } $headers .= "MIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n"; $headers .= " boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; $message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" . " name=\"{$name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; } SESSION_UNREGISTER('form_element0'); SESSION_UNREGISTER('form_element1'); SESSION_UNREGISTER('form_element2'); SESSION_UNREGISTER('form_element3'); if (@mail($email, $subject, $message, $headers)) {$_SESSION["formMessage"] = " ".'Thank you, your email has been sent.'." "; header("Location: contactus.php"); } else { $_SESSION["formMessage"] = "I'm sorry, there seems to have been an error trying to send your email. Please try again."; header("Location: contactus.php"); } } ?> Thanks!
×
×
  • 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.