Form post 2 msql


Hello Unbounce Community,
I have already read a few instructions but unfortunately I can not get it.

It is about the following landing page:

I would like to send the form data to:

https://www.swissbutler.ch/kontakt/check.php

Code:

<?php 

include_once('libx/phpm/class.phpmailer.php');

$config_mail_sender = "service@swissbutler.ch";
$config_mail_sender_name = "service@swissbutler.ch";
$config_mail_return = "service@swissbutler.ch";
$config_mail_smtp_host = "xxx";
$config_mail_smtp_user = "service@swissbutler.ch";
$config_mail_smtp_pass = "xxx";

mysql_connect('localhost', 'cbwe', 'eweqe234');
	mysql_select_db("xwewq") or die("Es ist ein Fehler aufgetreten. Bitte senden Sie uns eine E-Mail an service@swissbutler.ch");

$nichtspeichern = 0;

$fn = mysql_real_escape_string($_REQUEST['firstname']);
$ln = mysql_real_escape_string($_REQUEST['lastname']);
$em = mysql_real_escape_string($_REQUEST['email']);
$ph = mysql_real_escape_string($_REQUEST['phone']);
$st = mysql_real_escape_string($_REQUEST['street']);
$pl = mysql_real_escape_string($_REQUEST['plz']);
$ort = mysql_real_escape_string($_REQUEST['ort']);


//PLZ gršsser oder kleiner als 4 Zeichen
if (strlen($pl) > 4 || strlen($pl) < 4) {
//	$nichtspeichern = 1;
}

// Vorname und Nachname der Geleiche
if ( $fn == $ln) {
	//$nichtspeichern = 1;
}


$nachricht = toASCII(mysql_real_escape_string($_REQUEST['nachricht'])) ;
  //$nachricht = iconv("utf-8","ascii//TRANSLIT",mysql_real_escape_string($_REQUEST['nachricht'])) ;


    function toASCII( $str )
    {
        return strtr(utf8_decode($str), 
            utf8_decode('…€†šŠŸ'),
            'OAUoau');
    }
    

if ( isset($_POST["submit"]) && $nichtspeichern == 0 ){
	
	
	
	mysql_query("INSERT INTO t_kontakte (ko_mandatID, koVorname, koNachname, koStrasse, koPlz, koOrt, koTel, koEmail, koAnfrage)
	VALUES('56', '$fn', '$ln', '$st', '$pl', '$ort', '$ph', '$em', '$nachricht') ") or die(mysql_error());  
	
	
	$timestamp = time();
	$aktuellDatum = date("d-m-Y",$timestamp);

	
	
	
	
	
	  $mail             = new PHPMailer();
	  $mail->IsSMTP(); // telling the class to use SMTP
	  $mail->Host       = $config_mail_smtp_host; // SMTP server
	  $mail->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
	  $mail->SMTPAuth   = true;                  // enable SMTP authentication
	  $mail->Port       = 465;                    // set the SMTP port for the GMAIL server
	  $mail->Username   = $config_mail_smtp_user; // SMTP account username
	  $mail->Password   = $config_mail_smtp_pass;        // SMTP account passwor
	  $mail->SetFrom($config_mail_sender, $config_mail_sender);
	  $mail->AddReplyTo($em, $em);
	  
	  $address = "service@swissbutler.ch";
	  $mail->AddAddress($address, '');
	  $mail->Subject = html_entity_decode("Anfrage SwissButler",ENT_QUOTES,'ISO-8859-1') ;
	  $body = "Hallo Team<br> <br>	   
	  Datum: ".$aktuellDatum." <br>
Vorname: ".$fn." <br>
Nachname: ".$ln." <br>
Strasse: ".$st." <br>
PLZ ".$pl." <br>
Ort ".$ort." <br>
<br>
Telefon: ".$ph." <br>
E-Mail: ".$em." <br>
<br>
Nachricht: <br>".$nachricht." <br>
<br>";
	 
	  $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
	  $mail->MsgHTML(html_entity_decode($body,ENT_QUOTES,'ISO-8859-1')) ;
	

	  if(!$mail->Send()) {
	    echo "Fehler! Leider konnten wir die Nachricht nicht versenden. Sie erreichen uns unter 044 777 3000.";//$mail->ErrorInfo;
	  } else { ?>

	  	 <!-- Google Code for SwissButler - Contact Conversion Page -->
		<script type="text/javascript">
		/* <![CDATA[ */
		var google_conversion_id = 1070949717;
		var google_conversion_language = "en";
		var google_conversion_format = "3";
		var google_conversion_color = "ffffff";
		var google_conversion_label = "f82JCMWTtG0Q1crV_gM";
		var google_remarketing_only = false;
		/* ]]> */
		</script>
		<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
		</script>
		<noscript>
		<div style="display:inline;">
		<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1070949717/?label=f82JCMWTtG0Q1crV_gM&amp;guid=ON&amp;script=0"/>
		</div>
		</noscript>
	  	
	 <?php  

	 
	 
	 
	  $mails             = new PHPMailer();
	  $mails->IsSMTP(); // telling the class to use SMTP
	  $mails->Host       = $config_mail_smtp_host; // SMTP server
	  $mails->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
	  $mails->SMTPAuth   = true;                  // enable SMTP authentication
	  $mails->Port       = 465;                    // set the SMTP port for the GMAIL server
	  $mails->Username   = $config_mail_smtp_user; // SMTP account username
	  $mails->Password   = $config_mail_smtp_pass;        // SMTP account passwor
	  $mails->SetFrom($config_mail_sender, $config_mail_sender);
	  $mails->AddReplyTo($em, $em);
	  
	  $addr = $em;
	  $mails->AddAddress($addr, '');
	  $mails->Subject = html_entity_decode("Ihre Anfrage bei SwissButler.ch",ENT_QUOTES,'ISO-8859-1') ;
	  	  
	  $bodys = "Guten Tag ".$fn." ".$ln."<br><br>Vielen Dank f&uuml;r Ihre Anfrage.<br><br>Unser Team wird Ihre Anfrage innert k&uuml;rze bearbeiten und sich mit Ihnen in Verbindung setzen.<br><br>Ihr SwissButler Team | www.swissbutler.ch";
	 
	  $mails->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
	  $mails->MsgHTML(html_entity_decode($bodys,ENT_QUOTES,'ISO-8859-1')) ;
	 
	  if(!$mails->Send()) {
	   // echo "Fehler! Leider konnten wir die Nachricht nicht versenden. Sie erreichen uns unter 044 777 3000.";//$mail->ErrorInfo;
	  } else {
	  
	  }
	 
	 
	 
	 
	  }
	  

}


$v_redirect = "kontakt_danke.html";
header("Location: $v_redirect");


?>

What I already did:

image

Postform data to url.
with "append form data to url and without

Field name and ID changed.

When I make a normal php form it works:

code:

<form action="check.php" method="post" name="kformer">

	
	
      <label for="firstname">Vorname</label>
      <input type="text" id="firstname" name="firstname"> <br />
		
      <label for="lastname">Nachname</label>
      <input type="text" id="lastname" name="lastname" required><br />
		
      <label for="email">E-Mail Adresse</label>
      <input type="email" id="email" autocomplete="off" name="email" required></input><br />
      
      <label for="lastname">Telefonnummer</label>
      <input type="tel" id="phone" name="phone" required><br />
      
      <label for="street">Strasse</label>
      <input type="text" id="street" name="street"><br />
      
      <label for="plz">Plz</label>
      <input type="text" id="plz" name="plz" required><br />
      
      <label for="ort">Ort</label>
      <input type="text" id="ort" name="ort" required><br />
      
      <label for="nachricht">Nachricht</label>
      <textarea name="nachricht" id="nachricht" cols="21" rows="8"></textarea>


      <div id="order"> <input type="submit" name="submit" class="btn" value="Anfrage senden"> </div>
 
    

</form>

I would be very happy for help.
Unfortunately I did not manage with the instructions. Maybe I just just overlook something

Thanks a lot


0 replies

Be the first to reply!

Reply