General Question

pasoma89's avatar

Why my "send to a friend form" only works in safari?

Asked by pasoma89 (1points) April 2nd, 2009

Please help me!!!

<?php

if(count($_POST)) {

foreach(array(‘friendmail1’,‘friendmail2’,‘friendmail3’,‘email’,‘name’,‘dia_hora’) as $key) $_POST[$key] = strip_tags($_POST[$key]);
if(!is_secure($_POST)) { die(“Seguridad”);}

$emailto = “info@mysite.com”;

$esubject = “Una recomendaciĆ³n del sitio web se ha realizado”;

$emailtext = ”
$_POST[name] ha utilizado el formulario: invite a sus amigos. Su e-mail es $_POST[email]. Y la fecha indicada para la reuniĆ³n fue: $_POST[dia_hora] .

Con las siguientes personas:

$_POST[friendmail1]
$_POST[friendmail2]
$_POST[friendmail3]

”;

@mail(”$emailto”, $esubject, $emailtext, “From: $_POST[email]”);

$thankyou = “thanks.html”;

$tsubject = ”$_POST[name] te recomienda mysite”;

$ttext = ”
hi

check this out http://www.mysite.com

Atte

Tu amigo(a),

$_POST[name]
$_POST[email]

”;

@mail(”$_POST[friendmail1],$_POST[friendmail2],$_POST[friendmail3]”, $tsubject, $ttext, “FROM: $_POST[email]”);

header(“Location: $thankyou”);
exit;

}

function is_secure($ar) {
$reg = ”/(Content-Type|Bcc|MIME-Version|Content-Transfer-Encoding)/i”;
if(!is_array($ar)) { return preg_match($reg,$ar);}
$incoming = array_values_recursive($ar);
foreach($incoming as $k=>$v) if(preg_match($reg,$v)) return false;
return true;
}

function array_values_recursive($array) {
$arrayValues = array();
foreach ($array as $key=>$value) {
if (is_scalar($value) || is_resource($value)) {
$arrayValues[] = $value;
$arrayValues[] = $key;
}
elseif (is_array($value)) {
$arrayValues[] = $key;
$arrayValues = array_merge($arrayValues, array_values_recursive($value));
}
}
return $arrayValues;
}
?>

Observing members: 0 Composing members: 0

1 Answer

dynamicduo's avatar

I would start debugging this by creating one simple email form which I was able to verify working across all browsers, then gradually add snippets of the above code until it stopped working, then you know that the recently added code is where the problem lies.

Or, even better, create hard coded variables for all of your inputs, and try to get it running with zero user contribution whatsoever. That’s a good way to identify if it’s an input problem or a form problem etc.

Upon casual looking over of your code, my first suspects would be the multiple-lined $email_text variable, followed by the accents.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther