Bestätigung in Mailformular einfügen

Fragen zum Entwickeln eigener Addons?

Moderator: Sisko1990

Forum rules
Forumregeln
Locked
madesign
Joomla! Intern
Joomla! Intern
Posts: 72
Joined: Fri Nov 13, 2009 12:55 pm

Bestätigung in Mailformular einfügen

Post by madesign » Fri Nov 13, 2009 1:05 pm

Hallo,

ich habe nur geringe Kenntnisse von PHP und bekomme es nicht hin mit dem folgenden Script von http://www.gaijin.at/scrphpcform.php eine Bestätigungsmail an den Sender des Formulars zu schicken. Also an die Adresse die ausgefüllt wird. Bin für jede Hilfe dankbar.

Saludos, Michael

Hier mein modifiziertes script:

Code: Select all

<?php 

// *** Einstellungen *** 
$mail_to = 'Mailadress@mail.com'; // Ihre Mailadresse (Empfängeradresse) 

// ############################################################################# 
$from_name=GetParam('fromname'); 
$from_apellido=GetParam('fromapellido'); 
$from_mail=strtolower(GetParam('frommail')); 
$mail_subject=GetParam('mailsubject'); 
$mail_text=GetParam('mailtext'); 
$mail_text.="\n";
$mail_telefono.=GetParam('mailtelefono'); 

$send=GetParam('s'); 
$err_text=''; 
if(trim($from_name)=='') $err_text.='Por favor escriba su nombre!<br>';
if(trim($from_apellido)=='') $err_text.='Por favor escriba su apellido!<br>'; 
if(trim($from_mail)=='') 
  $err_text.='Por favor escriba su dirección de e-mail!<br>'; 
else 
  if(!ereg('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$',$from_mail)) 
    $err_text.='Por favor escriba su dirección de e-mail!<br>'; 
if(trim($mail_subject)=='') $err_text.='Por favor escriba su asunto!<br>'; 
if(trim($mail_text)=='') $err_text.='Por favor escriba su consulta!<br>'; 

// *** Zu langen Text abschneiden *** 
if(strlen($mail_text)>10000) { 
  $mail_text=substr($mail_text,0,10000).'... (Text wurde gekürzt!)'; 
} 
$from_name=str_replace(chr(34),"''",$from_name); 
$from_apellido=str_replace(chr(34),"''",$from_apellido); 
$mail_subject=str_replace(chr(34),"''",$mail_subject); 
$from_name=stripslashes($from_name); 
$from_apellido=stripslashes($from_apellido); 
$from_mail=stripslashes($from_mail); 
$mail_subject=stripslashes($mail_subject); 
$mail_text=stripslashes($mail_text); 

if (($send == '1') && ($err_text != '')) { 
  echo '<h2><b>ERROR:</h2>'; 
  echo $err_text.'</p>'; 
} 

if (($send != '1') || ($err_text != '')) { 
?> 

<form action="<?=GetParam('PHP_SELF','S')?>" method="post"> 
<table width="100%" border="0" cellpadding="0" cellspacing="12"> 
<tr>
<td align="right" nowrap="nowrap">Nombre*</td> 
<td><input name="fromname" type="text" value="<?=$from_name?>" size="50" /></td></tr> 
<tr>
<td align="right" nowrap="nowrap">Apellido*</td> 
<td><input type="text" name="fromapellido" size="50" maxlength="120" value="<?=$from_apellido?>"/></td></tr> 
<tr>
<td align="right" nowrap="nowrap">Telefono&nbsp;</td>
<td><input type="text" name="mailtelefono" size="50" maxlength="120" value="<?=$mail_telefono?>"/></td>
</tr>
<tr>
<td align="right" nowrap="nowrap">E-mail*</td>
<td><input type="text" name="frommail" size="50" maxlength="120" value="<?=$from_mail?>"/></td>
</tr>
<tr>
<td align="right" nowrap="nowrap">Asunto*</td>
<td><input type="text" name="mailsubject" size="50" maxlength="120" value="<?=$mail_subject?>"/></td></tr> 
<tr>
<td align="right" valign="top" nowrap="nowrap">Consulta*</td> 
<td><textarea cols="40" rows="10" name="mailtext"><?=$mail_text?></textarea></td></tr> 
<tr>
<td>*Requerido</td><td align="right"> 
<input type="hidden" value="1" name="s"/> 
<input id="button" type="image" accesskey="enter" src="imagen/botones/enviar.gif" value="ENVIAR" name="submit"/>
</td></tr> 
</table> 
</form> 

<?php 
} else { 
  $header="From: $from_name $from_apellido <$from_mail>\n"; 
  $header.="Reply-To: $from_mail\n"; 
  $header.="X-Mailer: PHP-ContactForm-Script\n"; 
  $header.="Content-Type: text/plain"; 
  $mail_date=gmdate('D, d M Y H:i:s').' +0000'; 
  $mail_text=$mail_text."\n"."Nombre: ".$from_name;
  $mail_text=$mail_text."\n"."\n"."Apellido: ".$from_apellido;
  $mail_text=$mail_text."\n"."\n"."Telefono: ".$mail_telefono;
  $mail_text=$mail_text."\n"."\n"."E-mail: ".$from_mail;
  $mail_text=$mail_text."\n"."\n"."Asunto: ".$mail_subject;
  $send=0; 
  if(@mail($mail_to,$mail_subject,$mail_text,$header)) 
  { 
    echo "<p>Su formulario ha sido enviado./p><p>Nos contactaremos con usted en 48 hs. para atender su consulta.</p>"; 
    echo "<p><a href=\"".GetParam('PHP_SELF','S')."?from_name=$from_name&from_mail=$from_mail\">Volver al formulario de contacto.</a></p>"; 
  }else{ 
    echo "<p><b>Cuando se envía el mensaje ha producido un error!</b></p>"; 
    echo "<p><a href=\"".GetParam('PHP_SELF','S')."?from_name=$from_name&from_mail=$from_mail&mail_subject=$mail_subject&mail_text="; 
    echo urlencode($mail_text)."\">Volver al formulario de contacto.</a></p>"; 
  } 
} 

function GetParam($ParamName, $Method = 'P', $DefaultValue = '') { 
  if ($Method == 'P') { 
    if (isset($_POST[$ParamName])) return $_POST[$ParamName]; else return $DefaultValue; 
  } else if ($Method == 'G') { 
    if (isset($_GET[$ParamName])) return $_GET[$ParamName]; else return $DefaultValue; 
  } else if ($Method == 'S') { 
    if (isset($_SERVER[$ParamName])) return $_SERVER[$ParamName]; else return $DefaultValue; 
  } 
} 
?> 

Markus66
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Tue Nov 24, 2009 8:26 am

Re: Bestätigung in Mailformular einfügen

Post by Markus66 » Thu Nov 26, 2009 8:23 am

du mußt die Funktion GetParam am Anfang einfügen


Locked

Return to “Entwicklerforum 1.0.x”