PHP Form mailer script problem.. Please help!


hello everyone!

 

thank in advance taking @ post me.

 

--------------->   new, designing second website ever... have stepped bit more 'complex' form in second website, designed "request quote" commercial appraisal. have set the  form , seems work fine. problem getting php script work form redirecting user thankyou.html page on site. also, recieving email correct information, script won't redirect user thankyou page.

 

this error after hitting submit button in browser:

 

 

the error

 

 

warning: file_get_contents(blockip.txt) [function.file-get-contents]: failed open stream: no such file or directory in /home/content/85/9643885/html/root_je/php/form2mail.php on line 50


deprecated: function ereg_replace() deprecated in /home/content/85/9643885/html/root_je/php/form2mail.php on line 111


warning: cannot modify header information - headers sent (output started @ /home/content/85/9643885/html/root_je/php/form2mail.php:50) in /home/content/85/9643885/html/root_je/php/form2mail.php on line 136

 

 

 

the php script

 

-------------->   using free script web found, have tried several, 1 has shown best results far: it's called form2mail.php , script reads:***********

 

 

 

 

<?php

# can use script submit forms or receive orders email.

$mailtoaddress = "jim@jeurmston.com"; // email address

$redirecturl = "http://www.jeurmston.com/thankyou.html"; // url of thank page.

$mailsubject = "[website form message]"; // subject of email

$sendhtml = false; //set "false" receive plain text e-mail

$servercheck = true; // if, reason can't send e-mails, set "false"

 

 

# copyright 2006 web4future.com =================== read ===================================================

 

 

# if asking name , email address in form, can name input fields "name" , "email".

# if this, message apear come email address , can click reply button answer it.

 

 

# block ip, add blockip.txt text file.

# chmod 777 blockip.txt file (run "chmod 777 blockip.txt", without double quotes)

# needed because script tries block ip tried hack it

 

 

# if have multiple selection box or multiple checkboxes, must name multiple list box or checkbox "name[]" instead of "name"

# must add "multiple" @ end of tag this: <select name="myselectname[]" multiple>

# have same checkboxes

 

 

/*****************************************************************

 

 

          web4future easiest form2mail (gpl).

          copyright (c) 1998-2006 web4future.com rights reserved.

          http://www.web4future.com/

          this script written george l. & calin s. web4future.com

 

 

          this program free software; can redistribute and/or modify

          it under terms of gnu general public license published by

          the free software foundation; either version 2 of license, or

          (at option) later version.

 

 

          this program distributed in hope useful,

          but without warranty; without implied warranty of

          merchantability or fitness particular purpose.  see the

          gnu general public license more details.

 

 

*****************************************************************/

 

 

# not edit below line unless know doing ===================================================

$w4fver =  "2.2";

$ip = ($_server['http_x_forwarded_for'] == "" ? $_server['remote_addr'] : $_server['http_x_forwarded_for']);

//function blockip

function blockip($ip) {

          $handle = @fopen("blockip.txt", 'a');

          @fwrite($handle, $ip."\n");

          @fclose($handle);

}

$w4fx = stristr(file_get_contents('blockip.txt'),getenv('remote_addr'));

if ($servercheck) {

          if (preg_match ("/".str_replace("www.", "", $_server["server_name"])."/i", $_server["http_referer"])) { $w4fy = true; } else { $w4fy = false; }

} else { $w4fy = true; }

if (($w4fy === true) && ($w4fx === false)) {

$w4fmessage = "<!doctype html public \"-//w3c//dtd html 4.01 transitional//en\" \"http://www.w3.org/tr/html4/loose.dtd\"><html>\n<head><meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\"></head><body><font face=3dverdana size=3d2>";

if (count($_get) >0) {

          reset($_get);

          while(list($key, $val) = each($_get)) {

                    $globals[$key] = $val;

                    if (is_array($val)) {

                              $w4fmessage .= "<b>$key:</b> ";

                              foreach ($val $vala) {

                                        $vala =stripslashes($vala);

                                        $vala = htmlspecialchars($vala);

                                        if (trim($vala)) { if (stristr($vala,"content-type:") || stristr($vala,"mime-version") || stristr($vala,"content-transfer-encoding") || stristr($vala,"bcc:")) { blockip($ip); die("illegal execution detected!"); }          }

                                        $w4fmessage .= "$vala, ";

                              }

                              $w4fmessage .= "<br>\n";

                    }

                    else {

                              $val = stripslashes($val);

                              if (trim($val)) { if (stristr($val,"content-type:") || stristr($val,"mime-version") || stristr($val,"content-transfer-encoding") || stristr($val,"bcc:")) { blockip($ip); die("illegal execution detected!"); }          }

                              if (($key == "submit") || ($key == "submit")) { }

                              else {           if ($val == "") { $w4fmessage .= "$key: - <br>\n"; }

                                                  else { $w4fmessage .= "<b>$key:</b> $val<br>\n"; }

                              }

                    }

          } // end while

}//end if

else {

          reset($_post);

          while(list($key, $val) = each($_post)) {

                    $globals[$key] = $val;

                    if (is_array($val)) {

                              $w4fmessage .= "<b>$key:</b> ";

                              foreach ($val $vala) {

                                        $vala =stripslashes($vala);

                                        $vala = htmlspecialchars($vala);

                                        if (trim($vala)) { if (stristr($vala,"content-type:") || stristr($vala,"mime-version") || stristr($vala,"content-transfer-encoding") || stristr($vala,"bcc:")) {blockip($ip); die("illegal execution detected!"); }          }

                                        $w4fmessage .= "$vala, ";

                              }

                              $w4fmessage .= "<br>\n";

                    }

                    else {

                              $val = stripslashes($val);

                              if (trim($val)) { if (stristr($val,"content-type:") || stristr($val,"mime-version") || stristr($val,"content-transfer-encoding") || stristr($val,"bcc:")) {blockip($ip); die("illegal execution detected!"); }          }

                              if (($key == "submit") || ($key == "submit")) { }

                              else {           if ($val == "") { $w4fmessage .= "$key: - <br>\n"; }

                                                  else { $w4fmessage .= "<b>$key:</b> $val<br>\n"; }

                              }

                    }

          } // end while

          }//end else

          $w4fmessage .= "<font size=3d1><br><br>\n sender ip: ".$ip."</font></font></body></html>";

    $w4f_what = array("/to:/i", "/cc:/i", "/bcc:/i","/content-type:/i","/\n/");

          $name = preg_replace($w4f_what, "", $name);

          $email = preg_replace($w4f_what, "", $email);

if (!$email) {$email = $mailtoaddress;}

          $mailheader = "from: $name <$email>\r\n";

          $mailheader .= "reply-to: $name <$email>\r\n";

          $mailheader .= "message-id: <". md5(rand()."".time()) ."@". ereg_replace("www.","",$_server["server_name"]) .">\r\n";

          $mailheader .= "mime-version: 1.0\r\n";

          if ($sendhtml) {

                    $mailheader .= "content-type: multipart/alternative;";

                    $mailheader .= "           boundary=\"----=_nextpart_000_000e_01c5256b.0aefe730\"\r\n";

          }

          $mailheader .= "x-priority: 3\r\n";

          $mailheader .= "x-mailer: php/" . phpversion()."\r\n";

          $mailheader .= "x-mimeole: produced web4future easiest form2mail $w4fver\r\n";

          if ($sendhtml) {

                    $mailmessage = "this multi-part message in mime format.\r\n\r\n";

                    $mailmessage .= "------=_nextpart_000_000e_01c5256b.0aefe730\r\n";

                    $mailmessage .= "content-type: text/plain;   charset=\"iso-8859-1\"\r\ncontent-transfer-encoding: quoted-printable\r\n\r\n";

                    $mailmessage .= trim(strip_tags($w4fmessage))."\r\n\r\n";

                    $mailmessage .= "------=_nextpart_000_000e_01c5256b.0aefe730\r\n";

                    $mailmessage .= "content-type: text/html;   charset=\"iso-8859-1\"\r\ncontent-transfer-encoding: quoted-printable\r\n\r\n";

                    $mailmessage .= "$w4fmessage\r\n\r\n";

                    $mailmessage .= "------=_nextpart_000_000e_01c5256b.0aefe730--\r\n";

          }

          if ($sendhtml === false) {

                    $mailheader .= "content-type: text/plain;   charset=\"iso-8859-1\"\r\ncontent-transfer-encoding: quoted-printable\r\n\r\n";

                    $mailmessage .= trim(strip_tags($w4fmessage))."\r\n\r\n";

          }

 

 

          if (!mail($mailtoaddress, $mailsubject, $mailmessage,$mailheader)) { echo "error sending e-mail!";}

          else { header("location: ".$redirecturl); }

} else { echo "<center><font face=verdana size=3 color=red><b>illegal execution detected!</b></font></center>";}

?>

 

   

<?php

# can use script submit forms or receive orders email.

$mailtoaddress = "jim@jeurmston.com"; // email address

$redirecturl = "http://www.jeurmston.com/thankyou.html"; // url of thank page.

$mailsubject = "[website form message]"; // subject of email

$sendhtml = false; //set "false" receive plain text e-mail

$servercheck = true; // if, reason can't send e-mails, set "false"

 

 

# copyright 2006 web4future.com =================== read ===================================================

 

 

# if asking name , email address in form, can name input fields "name" , "email".

# if this, message apear come email address , can click reply button answer it.

 

 

# block ip, add blockip.txt text file.

# chmod 777 blockip.txt file (run "chmod 777 blockip.txt", without double quotes)

# needed because script tries block ip tried hack it

 

 

# if have multiple selection box or multiple checkboxes, must name multiple list box or checkbox "name[]" instead of "name"

# must add "multiple" @ end of tag this: <select name="myselectname[]" multiple>

# have same checkboxes

 

 

          web4future easiest form2mail (gpl).

          copyright (c) 1998-2006 web4future.com rights reserved.

          http://www.web4future.com/

          this script written george l. & calin s. web4future.com

 

 

          this program free software; can redistribute and/or modify

          it under terms of gnu general public license published by

          the free software foundation; either version 2 of license, or

          (at option) later version.

 

 

          this program distributed in hope useful,

          but without warranty; without implied warranty of

          merchantability or fitness particular purpose.  see the

          gnu general public license more details.

 

 

 

# not edit below line unless know doing ===================================================

$w4fver =  "2.2";

$ip = ($_server['http_x_forwarded_for'] == "" ? $_server['remote_addr'] : $_server['http_x_forwarded_for']);

//function blockip

function blockip($ip) {

          $handle = @fopen("blockip.txt", 'a');

          @fwrite($handle, $ip."\n");

          @fclose($handle);

}

$w4fx = stristr(file_get_contents('blockip.txt'),getenv('remote_addr'));

if ($servercheck) {

          if (preg_match ("/".str_replace("www.", "", $_server["server_name"])."/i", $_server["http_referer"])) { $w4fy = true; } else { $w4fy = false; }

} else { $w4fy = true; }

if (($w4fy === true) && ($w4fx === false)) {

$w4fmessage = "<!doctype html public \"-//w3c//dtd html 4.01 transitional//en\" \"http://www.w3.org/tr/html4/loose.dtd\"><html>\n<head><meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\"></head><body><font face=3dverdana size=3d2>";

if (count($_get) >0) {

          reset($_get);

          while(list($key, $val) = each($_get)) {

                    $globals[$key] = $val;

                    if (is_array($val)) {

                              $w4fmessage .= "<b>$key:</b> ";

                              foreach ($val $vala) {

                                        $vala =stripslashes($vala);

                                        $vala = htmlspecialchars($vala);

                                        if (trim($vala)) { if (stristr($vala,"content-type:") || stristr($vala,"mime-version") || stristr($vala,"content-transfer-encoding") || stristr($vala,"bcc:")) { blockip($ip); die("illegal execution detected!"); }          }

                                        $w4fmessage .= "$vala, ";

                              }

                              $w4fmessage .= "<br>\n";

                    }

                    else {

                              $val = stripslashes($val);

                              if (trim($val)) { if (stristr($val,"content-type:") || stristr($val,"mime-version") || stristr($val,"content-transfer-encoding") || stristr($val,"bcc:")) { blockip($ip); die("illegal execution detected!"); }          }

                              if (($key == "submit") || ($key == "submit")) { }

                              else {           if ($val == "") { $w4fmessage .= "$key: - <br>\n"; }

                                                  else { $w4fmessage .= "<b>$key:</b> $val<br>\n"; }

                              }

                    }

          } // end while

}//end if

else {

          reset($_post);

          while(list($key, $val) = each($_post)) {

                    $globals[$key] = $val;

                    if (is_array($val)) {

                              $w4fmessage .= "<b>$key:</b> ";

                              foreach ($val $vala) {

                                        $vala =stripslashes($vala);

                                        $vala = htmlspecialchars($vala);

                                        if (trim($vala)) { if (stristr($vala,"content-type:") || stristr($vala,"mime-version") || stristr($vala,"content-transfer-encoding") || stristr($vala,"bcc:")) {blockip($ip); die("illegal execution detected!"); }          }

                                        $w4fmessage .= "$vala, ";

                              }

                              $w4fmessage .= "<br>\n";

                    }

                    else {

                              $val = stripslashes($val);

                              if (trim($val)) { if (stristr($val,"content-type:") || stristr($val,"mime-version") || stristr($val,"content-transfer-encoding") || stristr($val,"bcc:")) {blockip($ip); die("illegal execution detected!"); }          }

                              if (($key == "submit") || ($key == "submit")) { }

                              else {           if ($val == "") { $w4fmessage .= "$key: - <br>\n"; }

                                                  else { $w4fmessage .= "<b>$key:</b> $val<br>\n"; }

                              }

                    }

          } // end while

          }//end else

          $w4fmessage .= "<font size=3d1><br><br>\n sender ip: ".$ip."</font></font></body></html>";

    $w4f_what = array("/to:/i", "/cc:/i", "/bcc:/i","/content-type:/i","/\n/");

          $name = preg_replace($w4f_what, "", $name);

          $email = preg_replace($w4f_what, "", $email);

if (!$email) {$email = $mailtoaddress;}

          $mailheader = "from: $name <$email>\r\n";

          $mailheader .= "reply-to: $name <$email>\r\n";

          $mailheader .= "message-id: <". md5(rand()."".time()) ."@". ereg_replace("www.","",$_server["server_name"]) .">\r\n";

          $mailheader .= "mime-version: 1.0\r\n";

          if ($sendhtml) {

                    $mailheader .= "content-type: multipart/alternative;";

                    $mailheader .= "           boundary=\"----=_nextpart_000_000e_01c5256b.0aefe730\"\r\n";

          }

          $mailheader .= "x-priority: 3\r\n";

          $mailheader .= "x-mailer: php/" . phpversion()."\r\n";

          $mailheader .= "x-mimeole: produced web4future easiest form2mail $w4fver\r\n";

          if ($sendhtml) {

                    $mailmessage = "this multi-part message in mime format.\r\n\r\n";

                    $mailmessage .= "------=_nextpart_000_000e_01c5256b.0aefe730\r\n";

                    $mailmessage .= "content-type: text/plain;   charset=\"iso-8859-1\"\r\ncontent-transfer-encoding: quoted-printable\r\n\r\n";

                    $mailmessage .= trim(strip_tags($w4fmessage))."\r\n\r\n";

                    $mailmessage .= "------=_nextpart_000_000e_01c5256b.0aefe730\r\n";

                    $mailmessage .= "content-type: text/html;   charset=\"iso-8859-1\"\r\ncontent-transfer-encoding: quoted-printable\r\n\r\n";

                    $mailmessage .= "$w4fmessage\r\n\r\n";

                    $mailmessage .= "------=_nextpart_000_000e_01c5256b.0aefe730--\r\n";

          }

          if ($sendhtml === false) {

                    $mailheader .= "content-type: text/plain;   charset=\"iso-8859-1\"\r\ncontent-transfer-encoding: quoted-printable\r\n\r\n";

                    $mailmessage .= trim(strip_tags($w4fmessage))."\r\n\r\n";

          }

 

 

          if (!mail($mailtoaddress, $mailsubject, $mailmessage,$mailheader)) { echo "error sending e-mail!";}

          else { header("location: ".$redirecturl); }

} else { echo "<center><font face=verdana size=3 color=red><b>illegal execution detected!</b></font></center>";}

?>

 

 

 

 

the html form

 

------------------> , here html form page request_quote.html:*************************

 

 

 

 

 

<!doctype html><html><!-- instancebegin template="/templates/je_fullwidth.dwt" codeoutsidehtmlislocked="false" -->

 

 

<head>

          <script type="text/javascript" src="js/jquery.js"></script>

 

    <link href="css/styles.css" rel="stylesheet" type="text/css" media="screen">

 

 

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

          <meta http-equiv="content-type" content="cache" />

          <meta name="robots" content="index,follow" />

          <meta name="keywords" content="enter keywords" />

          <meta name="description" content="description here" />

<!-- instancebegineditable name="doctitle" -->

          <title>j.e. urmston request quote page</title>

   

                              <script>(function(h){h.classname=h.classname.replace(/\bno-js\b/,'js')})(d ocument.documentelement)</script>

                      <link href="css/validate.css" type="text/css" rel="stylesheet" media="screen,projection" />

           

                      <script type="text/javascript" src="js/validate.js"></script>

           

                               <script type="text/javascript">

                $(document).ready(function() {

                    $('form.required-form').simplevalidate({

                        errorelement: 'em'

                    });

                });

            </script>

   

          <!-- instanceendeditable -->

          <!-- google analytics code goes below here -->

       

   

    <!-- end google analytics code -->

<!-- instancebegineditable name="head" -->

<!-- instanceendeditable -->

</head>

 

 

<body>

 

 

<div id="outer">

 

 

<div id="wrapper">

 

                    <div id="logo">

                              <img src="images/logos/logo_1.jpg" />

                    </div>

 

                    <div id="social-media-icons">

                  <ul>

                      <li><a href="http://www.facebook.com" target="_blank"><img src="images/icons/facebook_32.jpg" alt="facebook link" /></a></li>

              <li><a href="http://www.twitter.com" target="_blank"><img src="images/icons/twitter_32.jpg" alt="twitter link" /></a></li>

              <li><a href="mailto:jeurmston@charter.net"><img src="images/icons/email_32.jpg" alt="email link" /></a></li>

            </ul>

 

                    </div>

 

 

                    <div id="topnav">

                              <ul>

                      <li><a href="index.html">home</a></li>

                <li><a href="about.html">about</a></li>

                <li><a href="services.html">services</a></li>

                <li><a href="gallery.html">gallery</a></li>

                <li><a href="contact.html">contact us</a></li>

            </ul>     

 

                    </div>

 

                    <div id="banner">

                  <img src="images/banner/reno1.jpg" alt="banner image of reno, nv @ night" />

 

                    </div>

 

        <div id="content-fullwidth"><!-- instancebegineditable name="content" -->

                    <div id="form-wrapper">

                      <h1>request quote</h1>

                      <p>lorem pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>

             

              <form class="required-form" action="php/form2mail.php" method="post">

               <input type="hidden" name="redirect" value="thankyou.html" />              

                <ol class="forms">

                   

                    <li>

                      <label for="name"> name of property:</label>

                      <input type="text" name="name" id="name" />

                    </li>

                   

                    <li>

                      <label for="company"> name of company/owner:</label>

                      <input type="text" name="company" id="company" />

                    </li>

                  

                    <li>

                      <label for="address1"><em class="required">*</em> address / apn #:</label>

                      <input type="text" name="address1" id="address1" class="required" />

                    </li>

                   

                    <li>

                      <label for="address2"> address 2:</label>

                      <input type="text" name="company" id="company" />

                    </li>

 

 

                    <li>

                      <label for="city"><em class="required">*</em> city:</label>

                      <input type="text" name="city" id="city" class="required" />

                    </li>

                   

                    <li>

                      <label for="state"> state:</label>

                                <p class="state">nevada</p>

                    </li>

 

 

 

 

                    <li>

                      <label for="property[]"><em class="required">*</em> use of property:</label>

                      <select name="property[]" multiple id="property[]" class="required">

                                <option value="select" selected>please select...

                        <option value="assembly">assembly/meeting place

                        <option value="commer">commercial general

                        <option value="health">health care

                        <option value="indust">industrial

                        <option value="land">land

                        <option value="lodgehosp">lodging & hospitality

                        <option value="mixed">mixed-use

                        <option value="multifam">multi-family

                        <option value="office">office

                        <option value="retail">retail

                        <option value="senior">senior housing

                        <option value="shopping">shopping center

                        <option value="special">special purpose

                        <option value="sportent">sports & entertainment

                       </select>

                    </li>

                   

                    <li>

                      <label for="report[]"><em class="required">*</em> report type:</label>

                                <select name="report[]" multiple id="report[]" class="required">

                                  <option value="select" selected>please select...

                            <option value="self">self contained

                            <option value="summary">summary

                            <option value="restricted">restricted

                            <option value="advise">unknown (please advise)

                        </select>

                    </li>

                   

 

 

                    <li>

                      <label for="client_company"> client company:</label>

                      <input type="text" name="client_company" id="client_company" class="required" />

                    </li>

           

                    <li>

                      <label for="client_first"><em class="required">*</em> client first name:</label>

                      <input type="text" name="client_first" id="client_first" class="required" />

                    </li>

  

                    <li>

                      <label for="client_last"><em class="required">*</em> client last name:</label>

                      <input type="text" name="client_last" id="client_last" class="required" />

                    </li>

 

 

                    <li>

                      <label for="client_phone"><em class="required">*</em> client phone:</label>

                      <input type="text" name="client_phone" id="client_phone" class="required" />

                    </li>

 

 

                    <li>

                      <label for="client_email"><em class="required">*</em> client email:</label>

                      <input type="text" name="client_email" id="client_email" class="required" />

                    </li>

 

 

  

                    <li>

                      <label for="message"> message:</label>

                      <textarea name="message" id="message" ></textarea>

                    </li>

 

 

                    <li class="buttons submit">

                      <button type="submit">submit</button>

                       </li>

 

 

                    <li class="buttons reset">

                      <button type="reset">reset form</button>

                       </li>

 

 

                        

                </ol>

              </form>

              </div>

 

                    <!-- instanceendeditable --></div>

           

 

                    <div id="footer">

                      <p class="footer-text">copyright 2012    |    all rights reserved   |    382designs</p>

    </div>

       

  </div>

  

</div>

 

 

</body>

<!-- instanceend --></html>

 

 

 

thank help!! have been killing myself trying figure out on own. appreciate can get!

the error means form script not compatible php version server running. php 5 no longer uses ereg function attached not function correctly without rewriting code of script.

 

if there way go php 4.x on server, function correctly. if not, either need re-write of ereg functions (ther plenty of references on google "ereg function deprecated") or php 5.x compatible form script.

 

i suggest www.tectite.com, have nice php5 compatible form mail script if don't plan write php yourself.



More discussions in Develop server-side applications in Dreamweaver


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support