FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


anyone know of a good php form processer script





starfish2007
I need a good php script to valadate a form I mostly need to check that everything is filled out but i also need it to make sure the email is a valad formate and the ability to make sure a drop down box i have is filled out i have set to have --- as the first option and injavascript i am able to not make the form submit in less something else but the first thing is selected unforchanly the php script i amusing does not seem to support drop downs. can anyone help me? thanks
ncwdavid
Well it depends on what you want the form to do. Like email the inforamation that was entered, insert it into a database or write it to a file and loads of other stuff. I would just suggest learning some PHP. Just a small bit of it. Just search in google for a little tutorial showing you how to work with forms in PHP its very basic PHP but allowing an unknown user enter information into your site can be dangerous if you dont do some security checks first so if you get a compatible script to do what you want or make one maybe you should post it here and We/I will help you to make it secure.

Goodluck.
starfish2007
well I have a php script that should be able to handle any type of field and email it to me but it does nott seem to work with drop downs i got my javascript tomake sure the drop down is filled out in the html form but the php scrip says igt is not filled out even though it is
you can see a coppy of the html part on my site by clicking the link to it on my signature here is the code of the php part.

[quote]
Code:
<?php
 echo 'someone elses code';

<?php
// L10Fm - v1.3 (11/10/06) (patched for XSS)
// requirements for session data -
//   1. LevelTen Hit Counter PHP v3.15 rel 3
//   2. L10HC_API.php v3.15 v1.0 rel 1
//

//////////////////////////////////////////////////////////////////////////////////////
//
// configuration variables
//
//////////////////////////////////////////////////////////////////////////////////////

// List all domains, including posible subdomains (e.g. www.) that are allowed to submit
// requests to this script and the domains of any posible recipient email address.

$validReferrers = array('computer-support.frih.net','www.computer-support.frih.net','computer-support.uni.cc','www.computer-support.uni.cc','216.32.85.170', '216.32.85.170','');

// Use the this array (or create new arrays with a different association) to replace
// setting fields in the form. Don't delete the 'default' array.

$formAction['default'] = array(
   'recipient' => 'support@computer-support.frih.net',
   'recipient_cc' => '',
   'recipient_bcc' => '',
   'subject' => 'computer support problem',
   'redirect' => 'http://www.computer-support.frih.net/success.htm',
   'email' => '',
   'realname' => '',
   'required' => '',
   'format' => 'html',
   'sesrep_max_items' => '10',
);

// If set to 0, the form can set the email recipient. For security reasons you should
// always set this variable to 1.

define('DISABLE_FORM_RECIPIENTS', 1);

//////////////////////////////////////////////////////////////////////////////////////
//
// Start of code
// Don't edit below this line
//
//////////////////////////////////////////////////////////////////////////////////////

$pageHdr = "<html><head><style>td {font: x-small, verdana, arial, helvetica, sans-serif;} h1 {font-size: medium;} .err {color: #EE0000; font-weight: bold;}</style></head><body bgcolor=#FFFFFF><table width='500' align=center><tr><td>";
$pageFtr = "</td></tr>\n</body></html>";

$L10_LIBLoaded = 0;
if(file_exists("L10_LIB.php")) {
   include_once("L10_LIB.php");
   $L10_LIBLoaded = 1;
}

$http_ref = $_SERVER['HTTP_REFERER'];
$array = parse_url($http_ref);
$a = $array['host'];

if(!in_array($a,$validReferrers)) {
   print "$pageHdr<p class=err>Invalid Referrer '$a'</p><p>Referrer does not have permission to access this LevelTen Formmail script.<p>For help on this issue, see <a href='http://www.leveltendesign.com/L10Apps/Fm/help_troubleshooting.php#invalidReferrer?hct=L10Fm-ErrMsg' target=_blank>LevelTen Formmail troubleshooting</a>$pageFtr";
   exit;
}

if(! $_POST['form_action'] or ! $formAction[$_POST['form_action']]['recipient']) {
   $fAIndex = 'default';
} else {
   $fAIndex = $_POST['form_action'];
}

$recipient  = (! DISABLE_FORM_RECIPIENTS && ($_POST['recipient'] != '')) ? $_POST['recipient'] : $formAction[$fAIndex]['recipient'];
$subject  = ($_POST['subject'] != '') ? $_POST['subject'] : $formAction[$fAIndex]['subject'];
$redirect = ($_POST['redirect'] != '') ? $_POST['redirect'] : $formAction[$fAIndex]['redirect'];
$email = ($_POST['email'] != '') ? $_POST['email'] : $formAction[$fAIndex]['email'];
$realname = ($_POST['realname']) ? $_POST['realname'] : $formAction[$fAIndex]['realname'];
$recipient_cc  = (! DISABLE_FORM_RECIPIENTS && ($_POST['recipient_cc'] != '')) ? $_POST['recipient_cc'] : $formAction[$fAIndex]['recipient_cc'];
$recipient_bcc  = (! DISABLE_FORM_RECIPIENTS && ($_POST['recipient_bcc'] != '')) ? $_POST['recipient_bcc'] : $formAction[$fAIndex]['recipient_bcc'];
$format = ($_POST['format'] != '') ? $_POST['format'] : $formAction[$fAIndex]['format'];
$required  = ($_POST['required'] != '') ? $_POST['required'] : $formAction[$fAIndex]['required'];
$sesrep_max_items  = ($_POST['sesrep_max_items'] != '') ? $_POST['sesrep_max_items'] : $formAction[$fAIndex]['sesrep_max_items'];
$recipient_secured  = ($_POST['recipient_secured'] != '') ? $_POST['recipient_secured'] : $formAction[$fAIndex]['recipient_secured'];

$a = explode("@",$recipient);
$a = array_pop($a);
if(!in_array($a,$validReferrers)) {
   print "$pageHdr<p class=err>Invalid Recipient '$recipient'</p><p> Email address does not have permission to relay through this LevelTen Formmail script.<p>For help on this issue, see <a href='http://www.leveltendesign.com/L10Apps/Fm/help_troubleshooting.php#invalidReferrer?hct=L10Fm-ErrMsg' target=_blank>LevelTen Formmail troubleshooting</a>$pageFtr";
   exit;
}

$rccArray = explode(",",$recipient_cc);
$recipient_cc = '';
if($rccArray[0] != '') {
   foreach($rccArray as $rcc) {
      $a = explode("@",$rcc);
      $a = array_pop($a);
      if(in_array($a,$validReferrers)) {
         $recipient_cc .= "$rcc,";
      }
   }
}
$recipient_cc = substr($recipient_cc,0,-1);

$rbccArray = explode(",",$recipient_bcc);
$recipient_bcc = '';
if($rbccArray[0] != '') {
   foreach($rbccArray as $rbcc) {
      $a = explode("@",$rbcc);
      $a = array_pop($a);
      if(in_array($a,$validReferrers)) {
         $recipient_bcc .= "$rbcc,";
      }
   }
}
$recipient_bcc = substr($recipient_bcc,0,-1);

$a = explode(",",$required);
if($a[0] != '') {
   foreach($a as $req) {
      if($_POST[$req] == '') {
         print "$pageHdr<p class=err>Required Field '$req' is missing!</p><p> You must input a value for this field before submitting<p align=center><a href=\"".$HTTP_REFERER."\">back to form</a>$pageFtr";
         exit;
      }
   }
}


$htmlFormat = (strtolower(substr($format,0,1)) == 'h');

$msg = '';
if($htmlFormat) {
   $msg = "<html><head><style>td {font: x-small, verdana, arial, helvetica, sans-serif;} .fldname {font-weight:bold;font-size:x-small;} .flddata {font-size:x-small;} .tblhdr { font-size:x-small;font-weight:bold;color:#FFFFFF;background-color=#000088}</style></head><body>\n";
   $msg .= "<table border=0 cellspacing=0 cellpadding=0 width=640>\n";
   $msg .= "<tr><td colspan=3 class='tblhdr'>Form Data</td></tr>\n";
} else {
   $msg = "Form data\n\n";
}

$bl0 = '';
$bl1 = '';
$ld = ' ';
$el = "\n\n";

$creditStrAdd = '';

if($htmlFormat) {
   $bl0 = '<tr bgcolor=#E8E8FF><td class="fldname" valign=top>';
   $bl1 = '<tr bgcolor=#FFFFFF><td class="fldname" valign=top>';
   $ld = '</td><td> &nbsp; </td><td width=80% class="flddata">';
   $el = "</td></tr>\n";
}
$i = 0;
foreach($_POST as $k => $v) {
   if($htmlFormat) {
      $v = str_replace("\n","<br>\n",$v);
   }
   if($i) {
      $msg .= "$bl0$k:$ld$v$el";
   } else {
      $msg .= "$bl1$k:$ld$v$el";
   }
   $i = !$i;
}

if(file_exists("L10HC_API.php")) {
   include("L10HC_API.php");
   $vID = getVID();
   if($htmlFormat) {
      $msg .= "<tr><td colspan=3><br>&nbsp;<br></td></tr>\n<tr><td colspan=3 border=1>";
      $creditStrAdd = ' &amp; LevelTen Hit Counter';
   } else {
      $msg .= "\n\n";
      $creditStrAdd = ' & LevelTen Hit Counter';
   }
   $msg .= getSessions($vID,$max_sessions,$recipient_secured,$htmlFormat+1);
   if($htmlFormat) {
      $msg .= "</td></tr>\n";
   } else {

   }
}

if($htmlFormat) {
   $msg .= "<tr><td colspan=3>&nbsp;</td></tr><tr><td colspan=3 align=center>Generated by<br>LevelTen Formmail$creditStrAdd<td></tr></table></body></html>\n";
} else {
   $msg .= "\n\nGenerated by LevelTen Formmail$creditStrAdd\n";
}



if (! preg_match("/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i", $recipient, $result)) {echo "Invalid recipient"; exit;}
if (strlen($recipient) > 80 or strlen($recipient_cc) > 200 or strlen($recipient_bcc) > 200) {echo "Possible hack attempt"; exit;}
if(stristr($subject, "Bcc:") or stristr($subject, "cc:") or stristr($subject, "to:")) {echo "Invalid content in subject"; exit;}
if(stristr($msg, "Bcc:") or stristr($msg, "cc:") or stristr($msg, "to:")) {echo "Invalid content in message"; exit;}
if(stristr($realname, "Bcc:") or stristr($realname, "cc:") or stristr($realname, "to:") or stristr($realname, "Content-type")) {echo "Invalid content"; exit;}
if(stristr($email, "Bcc:") or stristr($email, "cc:") or stristr($email, "to:")) {echo "Invalid content"; exit;}


$extraHeaders = "";
if($email) { $extraHeaders .= "From: \"". $realname ."\" <". trim($email) .">\r\n"; }
if($email) { $extraHeaders .= "Return-Path: ". trim($email) ."\r\n"; }
if($email) { $extraHeaders .= "Reply-To: ". trim($email) ."\r\n"; }
if($htmlFormat == 'h') { $extraHeaders .= "Content-type: text/html\r\n"; }
if($recipient_cc != '') { $extraHeaders .= "Cc: ". trim($recipient_cc) ."\r\n"; }
if($recipient_bcc != '') { $extraHeaders .= "Bcc: ". trim($recipient_bcc) ."\r\n"; }

$success = 1;
$success = mail($recipient,$subject,$msg,$extraHeaders);

if(!$success && $L10_LIBLoaded) {
   log_event("Unsuccesful Email Attempt: $recipient");
}

//print "mail($recipient,$subject,$msg,$extraHeaders)";
//print "$msg";

header("Location: $redirect");
?>

ncwdavid
There is lots of not need stuff in there for the form you are trying to process. I ment to post back on this earlier but had training and im going to bed noe but if you hold on for one more day ill post back a code ive made for it that will do what you want and be secure. That is unless someone else posts before me.

Goodluck.
starfish2007
ok you are the only one to respond so I am willing to try your code just no image varafacation plz im blind my self and so want my scripts to be as acessable to blindpeople as for sited people
sory if some of my words are some times blended together I try to avoid it but this the dissavantiges of editing what i right with a sckreen reder
ncwdavid
Ok I got it done but I just made it pretty quickly so here it is:
Code:

<?php
//your info
$to = "YOUR EMAIL HERE";
$subject = "SUBJECT OF EMAIL GOES HERE";

//defining the data
$email = $_POST['email'];
$name = $_POST['realname'];
$os = $_POST['oparating_system'];
$message = $_POST['message'];

//check if all fields were filled
if( (!$email)||(!$name)||($os=="---")||(!$message) ){
   echo "Please fix the following errors:<br><br>";
   if(!$email){
      echo "Email is a required field.<br>";
   }
   if(!$name){
      echo "Name is a required field.<br>";
   }
   if($os=="---"){
      echo "Please select a valid operating system.<br>";
   }
   if(!$message){
      echo "The message field is required.";
   }
}
else{

//check if the email address has any unwanted things
if( (eregi("to:", $email))||(eregi("cc:", $email))||(eregi("bcc:", $email)) ){
   echo "Please do not abuse the system!";
}
else{

//secure the message text
$message = strip_tags($message);

//email the data
if(mail($to, $subject, $message,"FROM: $name<$email>")){
   echo "It has been sent successfully.";
}
else{
   echo "There was a problem sending the form.";
}
}
}

?>


I just made it a few mins and I have it setup to work off of the names of the fields in the form at your site. Just change the two bits at the top in BIG LETTERS and it should work ok.

Post back and tell me how your get on.

P.S This script I made has not been checked for errors or anything yet so there might be one or two but there shouldnt be.
Related topics
Php form.
Free PHP/MySQL login script
does anyone know the contact script and the comment pages
Uplaoding images using php form :::: Help needed
PHP Form Question
Form Processing Email Not Sent
800$ frih for grab, php form small correction - urgent
Form handling in php is a pain in the neck
Make me a job application page in php and earn 110 FRIH$!
verzend formulier
formulieren maken testen mislukt
[php] travel agency script alike
my PHP code benchmark script that got some problems
Anyone care to help me with a simple PHP Form ?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.