eigen form script invoeren

hendrikshans schreef op 22.12.2012 om 16:47 uur

Hallo mede magix-ers,

 

Ik ben net aan het stoeien met webdesigner 8 van migix. Fijn programma en werkt fijne dan Dreamweaver waar ik eerst mee bezig was. Ik ben bezig de huidige site om te zetten naar die van Webdesign. Werkt goed. Ik vind alleen widgets niet zo super. Ze zijn freeware met reclame of niet zoals ik het zelf wil.

 

Het mooiste zou zijn als ik mijn eigen form kan gebruiken maar ik weet niet goed hoe ik die moet omzetten naar webdesign. Met plaatshouden en plaatsen in body of header lukt het niet. De php script die er aan vast hangt wordt niet meegenomen.

De huidige site is www.salondebohra.nl

Onder contact vind je het forumulier.

Ik heb hieronder de code gezet van het html forumulier en daar onder de php script.

 

Bedankt voor het meedenken!

 

<form id="form1" name="form1" method="post" action="mailformulier.php">
<!-- bij action moet je verwijzen naar mailformulier.php -->

<input type="hidden" name="required_fields" value="telefoon, email" />
<!-- bij value moet je id's van de verplichte velden ingeven -->

<input type="hidden" name="subject" value="Mail van Salon Debohra" />
<!-- bij value moet je de titel van de verstuurde mail ingeven -->

<input type="hidden" name="check_email_address" value="yes" />
<!-- bij value moet yes of no ingeven voor het checken van het email adres -->

<input type="hidden" name="after_url" value="bedankt.html" />
<!-- bij value moet je de pagina ingeven naar waar de bezoeker moet omgeleid worden na
het versturen van de mail -->

     <table width="535" border="1" cellspacing="2" cellpadding="2">
        <tr>
          <td width="197">Voornaam:</td>
          <td width="318"><input name="voornaam" type="text" id="voornaam" size="40" /></td>
        </tr>
        <tr>
          <td>Achternaam: (*) </td>
          <td><input name="achternaam" type="text" id="achternaam" size="40" /></td>
        </tr>
        <tr>
          <td>Adres:</td>
          <td><input name="adres" type="text" id="adres" size="40" /></td>
        </tr>
        <tr>
          <td>Postcode:</td>
          <td><input name="postcode" type="text" id="postcode" size="30" /></td>
        </tr>
        <tr>
          <td>Woonplaats:</td>
          <td><input name="woonplaats" type="text" id="woonplaats" size="30" /></td>
        </tr>
        <tr>
          <td>Telefoon/ Gsm: (*) </td>
          <td><input name="telefoon" type="text" id="telefoon" size="15" maxlength="11" />
          <input name="gsm" type="text" id="gsm" size="15" maxlength="11" /></td>
        </tr>
        <tr>
          <td>Email adres (*): </td>
          <td><input name="email" type="text" id="email" size="40" /></td>
        </tr>
        <tr>
          <td>Hoe bent u op onze site gekomen: </td>
          <td><textarea name="hoe" cols="40" id="hoe"></textarea></td>
        </tr>
        <tr>
          <td>Wat vindt u van onze site:</td>
          <td><textarea name="wat" cols="40" id="wat"></textarea></td>
        </tr>
        <tr>
          <td>Mist u iets op onze site: </td>
          <td><textarea name="mist" cols="40" id="mist"></textarea></td>
        </tr>
        <tr>
          <td>Opmerking/ vraag: </td>
          <td><textarea name="opmerking" cols="40" rows=" 8" id="opmerking"></textarea></td>
        </tr>
        <tr>
          <td><span style="font-size: 10px">(*) wij vragen u deze velden in te vullen zodat wij indien gewenst contact met u op kunnen nemen.</span> </td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>Velden leeg maken: </td>
          <td><input name="Opnieuw" type="reset" id="Opnieuw" value="Opnieuw" /></td>
        </tr>
        <tr>
          <td>Versturen:</td>
          <td><input name="Versturen" type="submit" id="Versturen" value="Versturen" /></td>
        </tr>
      </table>
    </form>
    <p align="center" class="style6">&nbsp;</p>

 

PHP script

 

<?
$your_email_address="contact@salondebohra.nl";

if(empty($_GET) && empty($_POST)) {
die('Ongeldige actie');
}

// Emular register_globals on
if (!ini_get('register_globals')) {
$superglobales = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET);
if (isset($_SESSION)) {
  array_unshift($superglobales, $_SESSION);
}
foreach ($superglobales as $superglobal) {
  extract($superglobal, EXTR_SKIP);
}
}

// to prevent header injection
if (eregi("\r",$_POST['your_email_address']) || eregi("\n",$_POST['your_email_address'])){
     exit;
}

// kick anyone whoever tried to inject a header in the form
foreach( $_POST as $value ){
if( strpos($value,'Content-Type:') !== FALSE ){
  exit;
}
}


$fields = array_keys($_POST);

function headfunction($url) {
header ("Location: $url");
}

// protect the variable $reserved_vars
if(isset($reserved_vars)) {
unset($reserved_vars);
}
$reserved_vars = array("css_file", "background_color", "background_image", "text_color", "link_color", "visited_link_color", "active_link_color", "font_name", "font_size", "highlight_color", "required_fields", "after_url", "check_email_address", "subject", "your_email_address", "env_report", "owner_name", "autoresponse", "response_subject", "response_mail", "dodosmail_header_file", "dodosmail_footer_file");

function include_dodosmail_header($dodosmail_header_file) {
global $reserved_vars;
foreach($reserved_vars as $reserved_var) {
  global $$reserved_var;
}

if(is_file($dodosmail_header_file)) {
  include_once($dodosmail_header_file);
  return;
} else {
  echo "<html>\n";
  echo "<head>\n";
  echo "<title>\n";
  echo "DodosMail\n";
  echo "</title>\n";
  if($css_file != "")
   echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$css_file\">\n";
  echo "</head>\n";
  echo "<body bgcolor=\"$background_color\" background=\"$background_image\" text=\"$text_color\" link=\"$link_color\" vlink=\"$visited_link_color\" alink=\"$active_link_color\">\n";
  echo "<font face=\"$font_name\" size=\"$font_size\">\n";
}
}

function include_dodosmail_footer($dodosmail_footer_file) {
global $reserved_vars;
foreach($reserved_vars as $reserved_var) {
  global $$reserved_var;
}
if(is_file($dodosmail_footer_file)) {
  include_once($dodosmail_footer_file);
  return;
} else {
  echo "</font>\n</body>\n</html>";
}
}

function dodosmail_error_handle($msg) {
global $highlight_color;
if(isset($highlight_color)) {
  $extra_begin = "<font color=\"".$highlight_color."\">";
  $extra_end = "</font>";
} else {
  $extra_begin = "<span class=\"DodosMailErrorHighLight\">";
  $extra_end = "</span>";
}

return $extra_begin.$msg.$extra_end;
}

// checking required fields
// in case they used comma and space, replace
if(strstr($required_fields, ", ")) {
$required_fields = str_replace(", ", ",", $required_fields);
} else {
$required_fields = $required_fields;
}
$required_fields = explode(",", $required_fields);

for($i = 0; $i < count($required_fields); $i++) {
$required_var_name = $required_fields[$i];
if(empty($$required_var_name)) {
  include_dodosmail_header($dodosmail_header_file);
  echo "<p class=\"DodosMailError\">Zou u zo vriendelijk willen zijn de velden: <h4>Achternaam, Telefoon en emailadres</h4> in te vullen? Als u op terug klikt, gaat u terug naar het formulier. Dank u wel";
  echo "<br /><br /><a href=\"javascript:history.back(1)\">Terug</a>\n";
  echo "</p>\n";
  include_dodosmail_footer($dodosmail_footer_file);
  exit;
}
}
if($check_email_address == "yes" && !empty($email)) {
if(!check_email($email)) {
  include_dodosmail_header($dodosmail_header_file);
  echo "<p class=\"DodosMailError\">Fout - het adres ".dodosmail_error_handle($email)." is niet geldig.\n";
  echo "<br /><br /><a href=\"javascript:history.back(1)\">Terug</a>\n";
  echo "</p>\n";
  include_dodosmail_footer($dodosmail_footer_file);
  exit;
}
}


for($i = 0; $i < count($fields); $i++) {
$actual_var = $fields[$i];
if(in_array($actual_var, $reserved_vars)) {
  $inside_mail = $inside_mail;
} else {
  if(is_array($$actual_var)) {
   $inside_mail.= "$actual_var: ";
   foreach($$actual_var as $actual_val) {
    $inside_mail.= "$actual_val ";
   }
   $inside_mail.= "\n";
  } else {
   $actual_val = stripslashes($$actual_var);
   $inside_mail.= "$actual_var: $actual_val\n";
  }
}
}

// getting other information from the form
$cname = gethostbyaddr($_SERVER[REMOTE_ADDR]);
$inside_mail.=
"
-----------------------------------------------------------------------
SENDER INFO:
IP: $_SERVER[REMOTE_ADDR]
Computer Name: $cname
Browser Type: $_SERVER[HTTP_USER_AGENT]
Page Referer: $_SERVER[HTTP_REFERER]
-----------------------------------------------------------------------
";

 


$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
$headers .= "X-Mailer: DodosMail 2.0 http://regretless.com/scripts/\r\n";
$headers .= "Content-type: text/plain; charset=\"iso-8859-1\"\r\n";
//$headers .= "Date: ".date("R")."\r\n";
$headers .= "From: $name <$email>\r\n";

$success = mail($your_email_address, $subject, $inside_mail, $headers);
if($success) {
if($autoresponse == "yes") {
  $response_subject = stripslashes($response_subject);
  $response_mail = stripslashes($response_mail);
  mail($email, $response_subject, $response_mail, "From: $owner_name <$your_email_address>");
}
if($after_url == "") {
  // out put send info
  include_dodosmail_header($dodosmail_header_file);


  echo "<p>\n";
 
  echo "Het formulier is verzonden!</p><ul>";
  for($i = 0; $i < count($fields); $i++) {
   $actual_var = $fields[$i];
   if(in_array($actual_var, $reserved_vars))
    echo "";
   else {
    if(is_array($$actual_var)) {
     echo "<li>$actual_var: ";
     foreach($$actual_var as $actual_val) {
      echo "$actual_val ";
     }
     echo "</li>\n";
    } else {
     $actual_val = stripslashes($$actual_var);
     echo "<li>$actual_var: $actual_val</li>\n";
    }
   }
  }
  echo "</ul>\n<p></p>";
  include_dodosmail_footer($dodosmail_footer_file);
  exit;
} else {
headfunction($after_url);
}
} else {
include_dodosmail_header($dodosmail_header_file);
echo "<p class=\"DodosMailError\">Fout - Het formulier is tijdelijk niet bruikbaar, gebruik ".dodosmail_error_handle($your_email_address)." om contact op te nemen.\n";
echo "<br /><br /><a href=\"javascript:history.back(1)\">Terug</a>\n";
echo "</p>\n";
include_dodosmail_footer($dodosmail_footer_file);
exit;
}

 

function check_email($email) {
if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) ||
  (preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) {
  return true;
}
return false;
}

 

?>

Reacties

Nog 0 reacties - Schrijf de eerste reactie