Tweakers, probleempje met het contact script, ik heb 5 boxes;
-naam
-telefoon
-from
-subject
-body
Probleem is dat niet alle boxes worden gecontroleerd en dat ik niet alle onderwerpen te zien krijg in me mail!
ben er al een tijd mee aan het stoeien maar kom er maar niet uit....
Php script is als volgt;
<?php
$nofrom="U heeft geen e-mail ingevuld";
$nobody="U heeft geen bericht ingevuld.";
$nonaam="U heeft geen naam ingevuld";
$notelefoon="U heeft geen telefoonnummer ingevuld";
$subjectbig="Naam/Telefoonnummer of Ref.nr. is te lang";
$frombig="Het e-mail adres klopt niet";
$invalidfrom="Er is iets fout gegaan, graag alle gegevens invullen";
$bodybig="Het bericht is te lang.";
require("contact_info.php");
function alphanum($string,$allow)
{
$ret = "";
$temp=explode("A",$allow);
for($x = 0; $x < strlen($string); $x++)
{
if ((($string[$x] >= "A") && ($string[$x] <= "Z")) || (($string[$x] >= "a") && ($string[$x] <= "z")) || (($string[$x] >= "0") && ($string[$x] <="9")))
{
$ret .= $string[$x];
}
else
{
$i=0; $count=sizeof($temp);
while ($count--)
{
if ($temp[$i]!="")
{
if (strpos($string[$x],$temp[$i])!==FALSE)
{
$ret .= $string[$x];
$count=0;
}
}
$i++;
}
}
}
return($ret);
}
function do_readfile_string(&$destination,$filename)
{
$destination=file_get_contents($filename);
if ($destination===FALSE) { return(0); } else { return(1); }
}
function do_readfile_array(&$destination,$filename)
{
$destination=file($filename);
if ($destination===FALSE) { return(0); } else { return(1); }
}
function write_file($data,$filename)
{
global $file_path;
$filename=$file_path . $filename;
ignore_user_abort(true);
$ret=0;
if ($fd=fopen($filename,"w"))
{
if (flock($fd,2))
{
fwrite($fd,$data);
flock($fd,3);
$ret=1;
}
fclose($fd);
ignore_user_abort(false);
return($ret);
}
else { ignore_user_abort(false); return(0); }
}
function append_file($data,$filename)
{
global $file_path;
$filename=$file_path . $filename;
ignore_user_abort(true);
$ret=0;
if ($fd=fopen($filename,"a"))
{
if (flock($fd,2))
{
fseek($fd, 0, SEEK_END);
fwrite($fd,$data);
flock($fd,3);
$ret=1;
}
fclose($fd);
ignore_user_abort(false);
return($ret);
}
else { ignore_user_abort(false); return(0); }
}
function showform($errormsg)
{
global $from,$subject,$naam,$telefoon,$body,$filename;
if (do_readfile_string(&$html,$filename))
{
$html=str_replace("<FROM>",$from,$html);
$html=str_replace("<SUBJECT>",$subject,$html);
$html=str_replace("<NAAM>",$subject,$naam,$html);
$html=str_replace("<TELEFOON>",$subject,$telefoon,$html);
$html=str_replace("<BODY2>",$body,$html);
$html=str_replace("<ERROR>",$errormsg,$html);
echo $html;
}
else
{
echo "Can't read $filename";
}
}
function error($errormsg)
{
showform($errormsg . "<P>");
exit;
}
$file_path="";
if (isset($HTTP_POST_VARS['from'])) { $from=stripslashes($HTTP_POST_VARS['from']); } else { $from=""; }
if (isset($HTTP_POST_VARS['subject'])) { $subject=stripslashes($HTTP_POST_VARS['subject']); } else { $subject=""; }
if (isset($HTTP_POST_VARS['naam'])) { $naam=stripslashes($HTTP_POST_VARS['naam']); } else { $naam=""; }
if (isset($HTTP_POST_VARS['telefoon'])) { $telefoon=stripslashes($HTTP_POST_VARS['telefoon']); } else { $telefoon=""; }
if (isset($HTTP_POST_VARS['body'])) { $body=stripslashes($HTTP_POST_VARS['body']); } else { $body=""; }
if (($from=="") && ($subject=="") && ($body=="")) && ($naam=="")) && ($telefoon=="")) { showform(""); exit; }
$from=htmlentities($from);
$naam=htmlentities($naam);
$telefoon=htmlentities($telefoon);
$subject=htmlentities($subject);
$body=htmlentities($body);
$bodybig=str_replace("<SIZE>",sprintf("%01d",$maxbody),$bodybig);
$maxsubject=500;
$maxfrom=100;
$to=$theiremail;
if ($from=="") { error($nofrom); }
if ($naam=="") { error($nonaam); }
if ($telefoon=="") { error($notelefoon); }
if ($body=="") { error($nobody); }
if (strlen($subject)>$maxsubject) { error($subjectbig); }
if (strlen($from)>$maxfrom) { error($frombig); }
if (strlen($body)>$maxbody) { error($bodybig); }
$from2=alphanum($from,'@A.A-A_A');
if ($from2!=$from) { error($invalidfrom); }
mail($to,$subject,$naam,$telefoon,$body,"From: $from\nReply-to: $naam\n");
header("Location: $url\n\n");
?>
-naam
-telefoon
-from
-subject
-body
Probleem is dat niet alle boxes worden gecontroleerd en dat ik niet alle onderwerpen te zien krijg in me mail!
ben er al een tijd mee aan het stoeien maar kom er maar niet uit....
Php script is als volgt;
<?php
$nofrom="U heeft geen e-mail ingevuld";
$nobody="U heeft geen bericht ingevuld.";
$nonaam="U heeft geen naam ingevuld";
$notelefoon="U heeft geen telefoonnummer ingevuld";
$subjectbig="Naam/Telefoonnummer of Ref.nr. is te lang";
$frombig="Het e-mail adres klopt niet";
$invalidfrom="Er is iets fout gegaan, graag alle gegevens invullen";
$bodybig="Het bericht is te lang.";
require("contact_info.php");
function alphanum($string,$allow)
{
$ret = "";
$temp=explode("A",$allow);
for($x = 0; $x < strlen($string); $x++)
{
if ((($string[$x] >= "A") && ($string[$x] <= "Z")) || (($string[$x] >= "a") && ($string[$x] <= "z")) || (($string[$x] >= "0") && ($string[$x] <="9")))
{
$ret .= $string[$x];
}
else
{
$i=0; $count=sizeof($temp);
while ($count--)
{
if ($temp[$i]!="")
{
if (strpos($string[$x],$temp[$i])!==FALSE)
{
$ret .= $string[$x];
$count=0;
}
}
$i++;
}
}
}
return($ret);
}
function do_readfile_string(&$destination,$filename)
{
$destination=file_get_contents($filename);
if ($destination===FALSE) { return(0); } else { return(1); }
}
function do_readfile_array(&$destination,$filename)
{
$destination=file($filename);
if ($destination===FALSE) { return(0); } else { return(1); }
}
function write_file($data,$filename)
{
global $file_path;
$filename=$file_path . $filename;
ignore_user_abort(true);
$ret=0;
if ($fd=fopen($filename,"w"))
{
if (flock($fd,2))
{
fwrite($fd,$data);
flock($fd,3);
$ret=1;
}
fclose($fd);
ignore_user_abort(false);
return($ret);
}
else { ignore_user_abort(false); return(0); }
}
function append_file($data,$filename)
{
global $file_path;
$filename=$file_path . $filename;
ignore_user_abort(true);
$ret=0;
if ($fd=fopen($filename,"a"))
{
if (flock($fd,2))
{
fseek($fd, 0, SEEK_END);
fwrite($fd,$data);
flock($fd,3);
$ret=1;
}
fclose($fd);
ignore_user_abort(false);
return($ret);
}
else { ignore_user_abort(false); return(0); }
}
function showform($errormsg)
{
global $from,$subject,$naam,$telefoon,$body,$filename;
if (do_readfile_string(&$html,$filename))
{
$html=str_replace("<FROM>",$from,$html);
$html=str_replace("<SUBJECT>",$subject,$html);
$html=str_replace("<NAAM>",$subject,$naam,$html);
$html=str_replace("<TELEFOON>",$subject,$telefoon,$html);
$html=str_replace("<BODY2>",$body,$html);
$html=str_replace("<ERROR>",$errormsg,$html);
echo $html;
}
else
{
echo "Can't read $filename";
}
}
function error($errormsg)
{
showform($errormsg . "<P>");
exit;
}
$file_path="";
if (isset($HTTP_POST_VARS['from'])) { $from=stripslashes($HTTP_POST_VARS['from']); } else { $from=""; }
if (isset($HTTP_POST_VARS['subject'])) { $subject=stripslashes($HTTP_POST_VARS['subject']); } else { $subject=""; }
if (isset($HTTP_POST_VARS['naam'])) { $naam=stripslashes($HTTP_POST_VARS['naam']); } else { $naam=""; }
if (isset($HTTP_POST_VARS['telefoon'])) { $telefoon=stripslashes($HTTP_POST_VARS['telefoon']); } else { $telefoon=""; }
if (isset($HTTP_POST_VARS['body'])) { $body=stripslashes($HTTP_POST_VARS['body']); } else { $body=""; }
if (($from=="") && ($subject=="") && ($body=="")) && ($naam=="")) && ($telefoon=="")) { showform(""); exit; }
$from=htmlentities($from);
$naam=htmlentities($naam);
$telefoon=htmlentities($telefoon);
$subject=htmlentities($subject);
$body=htmlentities($body);
$bodybig=str_replace("<SIZE>",sprintf("%01d",$maxbody),$bodybig);
$maxsubject=500;
$maxfrom=100;
$to=$theiremail;
if ($from=="") { error($nofrom); }
if ($naam=="") { error($nonaam); }
if ($telefoon=="") { error($notelefoon); }
if ($body=="") { error($nobody); }
if (strlen($subject)>$maxsubject) { error($subjectbig); }
if (strlen($from)>$maxfrom) { error($frombig); }
if (strlen($body)>$maxbody) { error($bodybig); }
$from2=alphanum($from,'@A.A-A_A');
if ($from2!=$from) { error($invalidfrom); }
mail($to,$subject,$naam,$telefoon,$body,"From: $from\nReply-to: $naam\n");
header("Location: $url\n\n");
?>