phpfreakjav Posted January 2, 2009 Share Posted January 2, 2009 <?php $works = $_POST['class']; if($works!="")//this is to trick spam bots, hidden field must be created in the form with name class. { exit(); } function email_validation($email){ $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'. '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; $quoted_pair = '\\x5c[\\x00-\\x7f]'; $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d"; $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22"; $domain_ref = $atom; $sub_domain = "($domain_ref|$domain_literal)"; $word = "($atom|$quoted_string)"; $domain = "$sub_domain(\\x2e$sub_domain)*"; $local_part = "$word(\\x2e$word)*"; $addr_spec = "$local_part\\x40$domain"; return preg_match("!^$addr_spec$!", $email) ? 1 : 0; } function clean_html($dirty_form) { foreach($dirty_form as &$val) /*most important concept *when passing an array by reference you must use & */ { $val = strip_tags($val); $val = stripslashes($val); } return $dirty_form; } function display($xarray) { $array=$xarray; print '<ul>'; foreach($array as $val) { print '<li>'; print $val; print '</li>'; } print '</ul>'; } $comment=$_POST['comments']; $name2 =$_POST['name']; $email =$_POST['email']; $phone =$_POST['phone']; $dirty_form=array($comment,$name2,$email,$phone); $clean_form=clean_html($dirty_form); display($clean_form); //displays all the values in any array in a list format. ?> <?php @$pfw_ip= $_SERVER['REMOTE_ADDR']; //Sending Email to form owner $headers = "From: [email protected]\n". "Reply-To:"; $pfw_subject = "Notary Training Contact Form"; $pfw_email_to = "[email protected]"; $pfw_message = " <html> <head> <style type='text/css'> th{text-align:right;height:30px;} table{line-heigth:200%;} h1{paddign:0;margin:0;font-size:large;font-family:Times New Roman;} </style> </head> <body> <h1>Notary Training Contact Form</h1> <table> <tr> <th>First Name:</th> <td>$clean_form[1] </td> </tr> <tr> <th>Email</th> <td>$clean_form[2]</td> </tr> <tr> <th>Phone Number</th> <td>$clean_form[3]</td> </tr> <tr> <th>User Comments</th> <td>$clean_form[0]</td> </tr> </table> </body> </html> " . ""; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: $email\n". "Reply-To: $email\n"; $ok=@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$headers ) ; ?> <?php include('thanks.php'); ?> Link to comment https://forums.phpfreaks.com/topic/139173-i-just-wanted-to-share-my-work-an-html-php-mail-code-based-on-arrays/ Share on other sites More sharing options...
DarkWater Posted January 2, 2009 Share Posted January 2, 2009 Why is this in Core PHP Hacking? *Sigh* Link to comment https://forums.phpfreaks.com/topic/139173-i-just-wanted-to-share-my-work-an-html-php-mail-code-based-on-arrays/#findComment-728002 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.