WebSite X5Help Center

 
Alexandre D.
Alexandre D.
User

Email Formular With Database  en

Auteur : Alexandre D.
Visité 6255, Followers 2, Partagé 56  
Mots-clés :: database,email,formular

Hi,

Website X5 Evolution 9 has some improvements, comparing to the last version.
However, I'm having some problems with my email form:

1 - I tried the option

Object E-Mail Formular => Send to data base

but it doesn't work properly

2 - I used the option "send email" and enclose my file using "require", after this I changed my old script, used in version 8, and alltough it works, I can't save images in data base AND, more important, I get a value "ARRAY" for several choices box, instead of the respective values (say, MetaTexis, Trados, etc.)

http://tradutempo.eu/DE/bewerber.html

Here is the code of both:

My script:

//Include the host information
include "host.inc.php";
mysql_connect($host,$user,$pass);
mysql_select_db($db);


$IP3 = $_SERVER["REMOTE_ADDR"];
$Art = $_POST["imObjectForm_1_1"];
$Taetigkeit = $_POST["imObjectForm_1_2"];
$Erfahrung = $_POST["imObjectForm_1_3"];
$Alter = $_POST["imObjectForm_1_4"];
$Geburtstag = $_POST["imObjectForm_1_5"];
$Anrede = $_POST["imObjectForm_1_6"];
$Vorname = $_POST["imObjectForm_1_7"];
$Name = $_POST["imObjectForm_1_8"];
$Adresse = $_POST["imObjectForm_1_9"];
$Zusatz = $_POST["imObjectForm_1_10"];
$PLZ = $_POST["imObjectForm_1_11"];
$Stadt = $_POST["imObjectForm_1_12"];
$LAND = $_POST["imObjectForm_1_13"];
$Telefon = $_POST["imObjectForm_1_14"];
$Handy = $_POST["imObjectForm_1_15"];
$Email = $_POST["imObjectForm_1_16"];
$URL = $_POST["imObjectForm_1_17"];
$Steuer = $_POST["imObjectForm_1_18"];
$MwSt = $_POST["imObjectForm_1_19"];
$Dienstleistung = $_POST["imObjectForm_1_20"];
$DienstAndere = $_POST["imObjectForm_1_21"];
$CAT1 = $_POST["imObjectForm_1_22"];
$CATandere = $_POST["imObjectForm_1_23"];
$Muttersprache1 = $_POST["imObjectForm_1_24"];
$MutterSprVariante = $_POST["imObjectForm_1_25"];
$AusgangsSpr1 = $_POST["imObjectForm_1_26"];
$AusgangsSpr2 = $_POST["imObjectForm_1_27"];
$Gebiet1 = $_POST["imObjectForm_1_28"];
$Gebiet2 = $_POST["imObjectForm_1_29"];
$Gebiet3 = $_POST["imObjectForm_1_30"];
$Wort = $_POST["imObjectForm_1_31"];
$Zeile = $_POST["imObjectForm_1_32"];
$Stunde = $_POST["imObjectForm_1_33"];
$Bild = $_POST["imObjectForm_1_35"];
$Referenzen = $_POST["imObjectForm_1_36"];
$sql = "INSERT INTO `bewerber` (`IP3`,`Art`,`Taetigkeit`,`Erfahrung`,`Alter`,`Geburtstag`,`Anrede`,

`Vorname`,`Name`,`Adresse`,`Zusatz`,`Stadt`,`PLZ`,`LAND`,`Telefon`,

`Handy`,`Email`,`URL`,`Steuer`,`MwSt`,`Dienstleistung`,`DienstAndere`,

`CAT1`,`CATandere`,`Muttersprache1`,`MutterSprVariante`,`AusgangsSpr1`,

`AusgangsSpr2`,`Gebiet1`,`Gebiet2`,`Gebiet3`,`Wort`,`Zeile`,`Stunde`,

`Referenzen`,`Bild`) values ('$IP3','$Art','$Taetigkeit','$Erfahrung','$Alter','$Geburtstag','$Anrede',

'$Vorname','$Name','$Adresse','$Zusatz','$Stadt','$PLZ','$LAND','$Telefon',

'$Handy','$Email','$URL','$Steuer','$MwSt','$Dienstleistung','$DienstAndere',

'$CAT1','$CATandere','$Muttersprache1','$MutterSprVariante','$AusgangsSpr1',

'$AusgangsSpr2','$Gebiet1','$Gebiet2','$Gebiet3','$Wort','$Zeile','$Stunde','$Bild',

'$Referenzen')";
mysql_query($sql);

mysql_close();"

Your script:

$settings['imEmailForm_9_1'] = array(
        "owner_email_from" => "E-Mail-Adresse",
        "owner_email_to" => "***",
        "customer_email_from" => "***",
        "customer_email_to" => "E-Mail-Adresse",
        "owner_message" => "Bewerbung",
        "customer_message" => "some text!",
        "owner_subject" => "your data",
        "customer_subject" => "your email",
        "owner_csv" => False,
        "customer_csv" => True,
        "confirmation_page" => "../bestaetigung.html"
    );

    if(substr(basename($_SERVER['PHP_SELF']), 0, 11) == "imEmailForm") {
        include "../res/x5engine.php";

        $answers = array(
        );

        $form_data = array(
            "Art des Bewerbers" => $_POST['imObjectForm_1_1'],
            "Tätigkeit" => $_POST['imObjectForm_1_2'],
            "Jahre Erfahrung" => $_POST['imObjectForm_1_3'],
            "Alter" => $_POST['imObjectForm_1_4'],
            "Geburtsdatum" => $_POST['imObjectForm_1_5'],
            "Anrede" => $_POST['imObjectForm_1_6'],
            "Vorname" => $_POST['imObjectForm_1_7'],
            "Name" => $_POST['imObjectForm_1_8'],
            "Adresse" => $_POST['imObjectForm_1_9'],
            "Zusatz" => $_POST['imObjectForm_1_10'],
            "PLZ" => $_POST['imObjectForm_1_11'],
            "Stadt" => $_POST['imObjectForm_1_12'],
            "Land" => $_POST['imObjectForm_1_13'],
            "Telefon" => $_POST['imObjectForm_1_14'],
            "Handy" => $_POST['imObjectForm_1_15'],
            "E-Mail-Adresse" => $_POST['imObjectForm_1_16'],
            "Webseite" => $_POST['imObjectForm_1_17'],
            "Steuernummer" => $_POST['imObjectForm_1_18'],
            "MwSt.-Nr." => $_POST['imObjectForm_1_19'],
            "Von Ihnen angebotenen Dienstleistungen" => $_POST['imObjectForm_1_20'],
            "Falls andere, welche" => $_POST['imObjectForm_1_21'],
            "Über welche CATs verfügen Sie" => $_POST['imObjectForm_1_22'],
            "Falls andere, welche" => $_POST['imObjectForm_1_23'],
            "Muttersprache" => $_POST['imObjectForm_1_24'],
            "Variante" => $_POST['imObjectForm_1_25'],
            "Ausgangssprache 1" => $_POST['imObjectForm_1_26'],
            "Ausgangssprache 2" => $_POST['imObjectForm_1_27'],
            "Gebiet 1" => $_POST['imObjectForm_1_28'],
            "Gebiet 2" => $_POST['imObjectForm_1_29'],
            "Gebiet 3" => $_POST['imObjectForm_1_30'],
            "Preis / Wort" => $_POST['imObjectForm_1_31'],
            "Preis / Zeile" => $_POST['imObjectForm_1_32'],
            "Preis / Stunde" => $_POST['imObjectForm_1_33'],
            "Referenzen" => $_POST['imObjectForm_1_36']
        );

        $files_data = array(
            "Lebenslauf" => $_FILES['imObjectForm_1_34'],
            "Bild" => $_FILES['imObjectForm_1_35']
        );

        if(@$_POST['action'] != "check_answer") {
            if(!isset($_POST['imJsCheck']) || $_POST['imJsCheck'] != "jsactive")
                die(imPrintJsError());
            if (isset($_POST['imCpt']) && !isset($_POST['imCptHdn']))
                die(imPrintJsError());
            if(isset($_POST['imSpProt']) && $_POST['imSpProt'] != "")
                die(imPrintJsError());
            $email = new imSendEmail();
            $email->sendFormEmail($settings['imEmailForm_9_1'], $form_data, $files_data);
            @header('Location: ' . $settings['imEmailForm_9_1']['confirmation_page']);
        } else {
            if(@$_POST['id'] == "" || @$_POST['answer'] == "" || strtolower(trim($answers[@$_POST['id']])) != strtolower(trim(@$_POST['answer'])))
                echo "0";
            else
                echo "1";
        }
    }

// End of file

include "bewerbungsformular2011.php";

Posté le
19 RéPONSES - 1 UTILES
Incomedia
Claudio N.
Incomedia

Hello Alexandre,

Which problem did you find with the send to database feature?

To send the data to a file, I suggest you to look how that data is structured. You can simply send it to a file where you do a print_r($_POST) to see what is coming from the email form.

The checkboxes are all arrays, so you should get the selected one in it. Wink

Lire plus
Posté le de Claudio N.
Alexandre D.
Alexandre D.
User
Auteur

Ok, one more time:

At version 8, I had the same problem.

In order to send an email to the destinatary, to me (admin) and to save the data in MySql, I had the above mentioned script linked to the mail script:

for example:

<?php
//Include the host information
include "mail_p012_8_00.php";
include "host.inc.php";
mysql_connect($host,$user,$pass);
mysql_select_db($db);

In this version I am founding the same problem:

1 - I want to send the data to me, to the destinatary and to save it in MySql.

The mail script works good BUT, if I want to link it with a DATA BASE and MySql

I receive an error message.

Now the question is:

How to link it?

What shall I write in ATTRIBUTE <name>?

Lire plus
Posté le de Alexandre D.
Incomedia
Claudio N.
Incomedia

To send an email to the customer and save your data to the DB, you should use the "Send to database" option. This will do everything automatic.

Which error is shown to you?

Lire plus
Posté le de Claudio N.
Alexandre D.
Alexandre D.
User
Auteur

It shows no errors and no redirection... only a white page

Lire plus
Posté le de Alexandre D.
Incomedia
Claudio N.
Incomedia

Can you provide me your project file (.iwzip)? You can upload it to your server and write here the download link. I'll check it and see what's wrong in it.

Thank you!

Lire plus
Posté le de Claudio N.
Alexandre D.
Alexandre D.
User
Auteur

If I do it, everyone will be able to download it? Undecided

Lire plus
Posté le de Alexandre D.
Incomedia
Claudio N.
Incomedia

You can set this post as private so it will be visible only to me and you.

Lire plus
Posté le de Claudio N.
Alexandre D.
Alexandre D.
User
Auteur

Hi

The database function also works perfectly.

The only condition is to fill both fields (Attribute + Name) with a value:

Object email form (Objekt E-Mail-Formular) => Insert field (Feld eingeben) => Options (Optionen) => Attribute + Name

Best regards!

Lire plus
Posté le de Alexandre D.
Alexandre D.
Alexandre D.
User
Auteur

One more consideration:

I also understood, that if the related data base has no tables, the mailform table will be automaticaly generated... BUT: the generated fields are all BLOB type, which should be used only with files and images. However: nice job!

Lire plus
Posté le de Alexandre D.
Incomedia
Claudio N.
Incomedia

Hi Alexandre,

The field is created as "text" but some servers, if there's no length specified for the fields, create it as a blob. Undecided

Lire plus
Posté le de Claudio N.
Alexandre D.
Alexandre D.
User
Auteur

Hi Claudio

Did you see the files?

The data base is created, but there still be an error while submiting the form values... : (

Best regards!

Lire plus
Posté le de Alexandre D.
Incomedia
Claudio N.
Incomedia

Hi Alexandre,

I did not see the server's file. Did you send them via email?

Anyway, if the table was created correctly, it means that the connection to your MySQL database can be established. Did you try to use field names (the "name attribute" option in the field advanced settings) without umlautes? It could be a problema on certain servers.

Thank you!

Lire plus
Posté le de Claudio N.
Alexandre D.
Alexandre D.
User
Auteur

Hi,

As soon as possible I will check the umlautest issue

Please take a look at:

http://answers.websitex5.com/post/5220

When form is submitted, the website shows an error message and the values are not submitted into database. Files are uploaded to server, unfortunately not into a particular folder, only to the server root...

Lire plus
Posté le de Alexandre D.
Alexandre D.
Alexandre D.
User
Auteur

...no, I can't find any umlautest!

Lire plus
Posté le de Alexandre D.
Incomedia
Claudio N.
Incomedia

Hi Alexandre,

I've tested your file. There's a field called "Alter" which is a keyword of MySQL. This does not allow to store the data as that keyword corrupt the query meant to store the data. I suggest to change the field name.

For the next update we'll add an escape for the field names so this problem will not be there anymore. Wink

Thank you!

Lire plus
Posté le de Claudio N.
hafiz aziz H.
hafiz aziz H.
User

Hello there..i also having a problem here...could you help me...

when i fill in all the form in order to submit..

it show this error.. "Unable to connect to database. Check your connection paramenters."

could you help me to solve the problem

Lire plus
Posté le de hafiz aziz H.
Incomedia
Claudio N.
Incomedia
hafiz aziz H.
Hello there..i also having a problem here...could you help me...when i fill in all the form in order to submit..it show this error.. "Unable to connect to database. Check your connection paramenters." could you help me to solve the problem

Seems that the script cannot connect to your database. Are you sure the connection parameters are correct? You may want to contact your hosting provider to get more info about that. Wink

Lire plus
Posté le de Claudio N.
hafiz aziz H.
hafiz aziz H.
User
Claudio N.
hafiz aziz H.Hello there..i also having a problem here...could you help me...when i fill in all the form in order to submit..it show this error.. "Unable to connect to database. Check your connection paramenters." could you help me to solve the problem Seems that the script cannot connect to your database. Are you sure the connection parameters are correct? You may want to contact your hosting provider to get more info about that.

Thanx..finally i have solved the problem..

the new things that i need help from you, could u give me a step by step on how can we make a register form for a user that they will have their own login user and password..?

sorry for bad language. thnx

Lire plus
Posté le de hafiz aziz H.
Incomedia
Claudio N.
Incomedia

Hi Hafiz,

That's a quite complicated procedure.

If you have already setup the form and the registration data is correctly saved into the database, you must now use a custom PHP code to check the login data when the user register and create a session. So you must to as follows:

  1. Create a custom login form (you can do it using an email form and selecting "Send to file" in its options).
  2. Create a custom PHP file which retrieves the data sent by the form and then create a session containing the user's data.
  3. In each protected page, add a custom PHP code which checks if the current user can access to it.

Wink

Lire plus
Posté le de Claudio N.