Changes to a mail function (Absolute beginner question)

Hello Forum

I need to make a basic change to a script that:
A. Send information to a mysql base and
B. Send a mail to a specific email address, when the information is added to the database:
mail(“[email protected]”, “Ein neues Testkonto wurde eingerichtet”, “Aktivieren Sie das Konto”);

The change I need is in part B.

I need to add company_name and company_adress1 to the mail. In the “Aktivieren Sie das Konto” part.

I hope there is an expert, who can show me how to do this.

(The script is live, so I don’t dare to make beginner experiments)

Best Regards


The script looks like this:

<?php // no direct access defined('_JEXEC') or die('Restricted access'); $task = strval(mosGetParam( $_REQUEST, 'task', '' ) ); switch($task) { default: case "view": require_once (JPATH_COMPONENT.DS.'default.php'); break; case "submit": try_kat(); break; } function try_kat(){ if (($_POST['company_name'] != '') AND ($_POST['company_adress1'] != '') AND ($_POST['company_postal_city'] != '') AND ($_POST['company_contact'] != '') AND ($_POST['company_phone'] != '') AND ($_POST['company_email'] != '') ) { $conn = mysql_connect("database_srv", "root", "hm0d5drwseanne") or die(mysql_error()); mysql_select_db(joomla, $conn) or die(mysql_error()); $sql = "SELECT COUNT(*) FROM kat.users WHERE '".$_POST['company_name']."' = username;"; $result = mysql_query($sql); $found = mysql_result($result, 0); if ($found == 0) { $sql = "INSERT INTO `kat`.`users` ( `id` , `system_created` , `system_closed` , `dbname` , `changed` , `created` , `approved_date` , `username` , `demo_account` , `beta` , `beta_panel` , `user_address1` , `user_address2` , `user_city` , `user_country` , `user_contactperson` , `user_phone` , `user_email` , `user_cvr` , `user_branch` ) VALUES ( NULL , '0', '2', 'kat_".$_POST['company_name']."', NOW( ) , NOW( ) , '0000-00-00 00:00:00', '".$_POST['company_name']."', '1', '0', '0', '".$_POST['company_adress1']."', '".$_POST['company_adress2']."', '".$_POST['company_postal_city']."', '".$_POST['company_country']."', '".$_POST['company_contact']."', '".$_POST['company_phone']."', '".$_POST['company_email']."', '".$_POST['company_cvr']."', '".$_POST['company_branch']."');"; mysql_query($sql); $sql = "UPDATE `kat`.`users` SET `dbname` = 'kat_".mysql_insert_id()."', `subname` = 'kat_".mysql_insert_id()."', `changed` = NOW( ) WHERE `users`.`id` = '".mysql_insert_id()."' LIMIT 1;"; mysql_query($sql); echo "Wir danken Ihnen für Ihr Interesse an Wir werden schnellstmöglich Ihr Testkonto einrichten und Ihnen eine E-Mail mit den erforderlichen Informationen zugehen lassen."; echo " "; echo " "; echo "Mit freundlichen Grüßen kat"; mail("[email protected]", "Ein neues Testkonto wurde eingerichtet", "Aktivieren Sie das Konto"); } else { echo "Das Unternehmen existiert bereits und kann nicht gewählt werden."; } } } ?>

This should work, my German is close to non-existant so I did my best. Try running the script somewhere that is not user facing first to check it works.

$name = $_POST[‘company_name’];
$address = $_POST[‘company_adress1’];

mail(“[email protected]”, “Ein neues Testkonto wurde eingerichtet”, “Aktivieren Sie das Konto für Firmenname: $name Adresse: $address”);


Thanks a lot maas. Works exactly as I wanted it to do.

This is a great forum!

Best Regards


Sponsor our Newsletter | Privacy Policy | Terms of Service