hoe dit invulformulier naar e-mailadres verzenden?

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

10/02/2004 06:56:00
Quote Anchor link
Hoe verstuur ik onderstaand forumulier nou naar een e-mailadres?






<<<<<< start of index.php >>>>>>

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php


include "array.php";

 // everything between these {} will be done when the form is submitted

if ($action == "sent")

{


     // $options is the array that contains all the questions and their specifics. It's located in array.php

    foreach ($options AS $number => $array)

    {


        if($array[type] == "radio" && $array[required] == "yes")

        {


             // this means none of the radiobuttons for this question have been checked

            if(!$radio[$number])

            {


                $error[$number] =  "<tr>\n<td colspan=\"3\">\n\t<font color=\"red\">You forgot to answer this question!</font>\n </td>\n</tr>\n";

            }

        }


        if($array[type] == "check" && $array[required] == "yes")

        {


             // this means none of the checkboxes for this question have been checked

            if (!$checkbox[$number])

            {


                $error[$number] = "<tr>\n<td colspan=\"3\">\n\t<font color=\"red\">You have to at least answer one of these options</font>\n </td>\n</tr>\n";

            }

        }


        if ($array[type] == "text" && $array[required] == "yes")

        {


             // this means nothing has been entered into the text field

            if (!$text[$number])

            {


                $error[$number] = "<tr>\n <td colspan=\"3\">\n\t<font color=\"red\">You forgot to answer this Question</font>\n </td>\n</tr>\n";

            }

        }


         // you can add as many of these as you want to, if more values have to be check for their validity

        if ($array[type] == "text" && $array[required] == "yes" && $array[special] == "email")

        {


             // this will check if the entered value is a valid email address

            if (!preg_match("/(\w+\-*)\@{1}(\w+\-?\w+)(\.\w+\-?\w+)*(\.{1}\w{2,3})$/", $text[$number]))

            {


                $error[$number] = "<tr>\n <td colspan=\"3\">\n\t<font color=\"red\">The email address you entered is not a valid one</font>\n </td>\n</tr>\n";

            }

        }

            

                

    }


    if (!$error)

    {


         // if the parser got to this point, it means everything required was filled in

         // and the values were valid ones. so do whatever you want to do here and then exit the script


         exit();

    }

}


?>


<html>

<body>

<form action="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $PHP_SELF; ?>
" method="post" name="submit_form">

<table border="0" cellpadding="0" cellspacing="1" bgcolor="#000000" width="80%">

<tr>

<td>

<table border="0" cellpadding="5" cellspacing="0" bgcolor="#CACACA" width="100%">

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php

foreach ($options AS $number => $array)

{


     // just delete $number if you don't want it to be displayed. But let the <td> intact

    echo $error[$number];

    echo "<tr>\n <td valign=\"top\" width=\"1%\">\n\t$number.\n </td>\n";

    echo " <td align=\"left\" valign=\"top\">\n\t$array[question]\n </td>\n";



    if ($array[type] == "radio")

    {


        echo " <td align=\"left\">\n\t";

        $count = 1;

        foreach ($array[options] AS $option)

        {


            if ($radio[$number] == $count)

            {


                $check = " checked";

            }


            else

            {

                $check = "";

            }


            echo "<input type=\"radio\" name=\"radio[$number]\" value=\"$count\"$check>$option $array[break]\n";

            $count++;

        }


        echo " </td>\n";

    }


    

    elseif ($array[type] == "check")

    {


        echo " <td align=\"left\">\n\t";

        $count = 1;

        foreach ($array[options] AS $option)

        {


            if ($checkbox[$number][$count] == "on")

            {


                $check = " checked";

            }


            else

            {

                $check = " ";

            }


            echo "<input type=\"checkbox\" name=\"checkbox[$number][$count]\"$check>$option $array[break]\n";

            $count++;

            

        }


        echo " </td>\n";

    }


    elseif ($array[type] == "text")

    {


        echo " <td align=\"left\">\n\t<input type=\"text\" name=\"text[$number]\" value=\"$text[$number]\" size=\"$array[size]\">\n </td>\n";

    }

}


?>


</table>

</td>

</tr>

<tr>

<td>

<table border="0" cellpadding="5" cellspacing="0" bgcolor="#CACACA" width="100%">

<tr>

<td align="center" width="50%">

<input type="submit" value="Submit Form">

</td>

<td align="center" width="50%">

<input type="reset" value="Reset Form">

</td>

</tr>

</table>

</td>

</tr>

</table>

<input type="hidden" name="action" value="sent">
</form>



</body>

</html>

<<<<<<< end of index.php >>>>>>>

<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>

<<<<<< start of array.php >>>>>>

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

 $options
= array(

        "1"    =>    array(

                    "type"        =>    "radio",

                    "question"    =>    "hoe oud ben je?",

                    "options"    =>    array("0-15","16-23","24-30","31-ouder"),

                    "break"        =>    "<br>",

                    "required"    =>    "yes"

                    ),

        "2"    =>    array(

                    "type"        =>    "check",

                    "question"    =>    "waar programmeer je in?",

                    "options"    =>    array("php","asp","geen van beide"),

                    "break"        =>    "  ",

                    "required"    =>    "yes"

                    ),

        "3"    =>    array(

                    "type"        =>    "text",

                    "question"    =>    "wat is je email adres",

                    "size"        =>    "30",

                    "required"    =>    "yes",

                    "special"    =>    "email"

                    )

        );


?>


<<<<<<< end of array.php >>>>>>>
Gewijzigd op 14/02/2004 13:19:00 door
 
PHP hulp

PHP hulp

19/04/2024 08:32:19
 

10/02/2004 17:46:00
Quote Anchor link
ziet er goed uit maar hoe kan ik de informatie als een bijvoegsel (.txt) bestand versturen als email?
 
Johan

Johan

10/02/2004 20:48:00
Quote Anchor link
wat wil je dan precies verzonden hebben, Nansjepansje(:S)

en wat is jouw vraag nouw pcies Patrick??
 
Elwin - Fratsloos

Elwin - Fratsloos

10/02/2004 21:59:00
Quote Anchor link
Resultaten van een form per e-mail verzenden is te vinden op http://www.phphulp.nl/php/scripts/2/113

Elwin
 

11/02/2004 06:24:00
Quote Anchor link
Nou Johan, ik wil gewoon dat alle gegevens die de mensen in gaan vullen, dat die naar m'n e-mailadres worden verstuurd. Maar hoe doe ik dat precies. Ik snap niet waar ik precies welk stukje script daarvoor moet plaatsen.

Bedankt voor de snelle reacties,

Nancy
 
B a s
Beheerder

B a s

11/02/2004 14:21:00
Quote Anchor link
Nancy,

Je kunt een e-mail versturen met 'mail()' functie van PHP.. Hier kun je zien hoe iemand anders het heeft gedaan:

http://www.phphulp.nl/php/scripts/2/12/
 

12/02/2004 07:13:00
Quote Anchor link
Heb hem al veranderd :-D code staat hier helemaal boveaan

Nu nog 1 probleempje, hij checkt niet of alle vragen wel zijn ingevuld. Hij geeft als je de pagina opent al aan dat je alle vragen nog niet hebt ingevuld.
Dat klopt natuurlijk niet.
En hij verstuurt toch een mailtje, ondanks dat (hij zegt) dat je niets hebt ingevuld.

Greetings Nancy


Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
include \"array.php\";

 // everything between these {} will be done when the form is submitted

if ($action == \"sent\") {
$bericht = \"\";
    $bericht = $bericht . \"Vraag 1,\". $text[\'Name\'] . \"<BR>\";
    $bericht = $bericht . \"Vraag 2,\". $text[\'e-mailadress\'] . \"<BR>\";

    $aantal = count($radio); //15 radio vragen
    for($x=1;$x<=$aantal;$x++){
        $bericht = $bericht . \"Vraag \" . ($x + 2) . \",\". $radio[$x] . \"<BR>\";
    }


    //echo $bericht;
    $bericht = str_replace(\"<BR>\", \"\\n\", $bericht);
    mail(\"nancy@brondijk.info\", \"Answers Assessment Tools\", $bericht);
echo \"Your answers were send succesfully, thanks for your time!\";

}




     // $options is the array that contains all the questions and their specifics. It\'s located in array.php

    foreach ($options AS $number => $array)

    {


        if($array[type] == \"radio\" && $array[required] == \"yes\")

        {


             // this means none of the radiobuttons for this question have been checked

            if(!$radio[$number])

            {


                $error[$number] =  \"<tr>\\n<td colspan=\\\"3\\\">\\n\\t<font color=\\\"red\\\">You forgot to answer this question!</span>\\n </td>\\n</tr>\\n\";

            }

        }


        if($array[type] == \"check\" && $array[required] == \"yes\")

        {


             // this means none of the checkboxes for this question have been checked

            if (!$checkbox[$number])

            {


                $error[$number] = \"<tr>\\n<td colspan=\\\"3\\\">\\n\\t<font color=\\\"red\\\">You have to at least answer one of these options</span>\\n </td>\\n</tr>\\n\";

            }

        }


        if ($array[type] == \"text\" && $array[required] == \"yes\")

        {


             // this means nothing has been entered into the text field

            if (!$text[$number])

            {


                $error[$number] = \"<tr>\\n <td colspan=\\\"3\\\">\\n\\t<font color=\\\"red\\\">You forgot to answer this Question</span>\\n </td>\\n</tr>\\n\";

            }

        }


         // you can add as many of these as you want to, if more values have to be check for their validity

        if ($array[type] == \"text\" && $array[required] == \"yes\" && $array[special] == \"email\")

        {


             // this will check if the entered value is a valid email address

               if (!preg_match(\"/^([a-z0-9_\\-]+\\.)*?[a-z0-9_\\-]+@([a-z0-9\\-_]{2,})\\.[a-z0-9\\-_]*(\\.[a-z0-9\\-_]{2,})*$/i\", $text[$number]))

            {


                $error[$number] = \"<tr>\\n <td colspan=\\\"3\\\">\\n\\t<font color=\\\"red\\\">The email address you entered is not a valid one</span>\\n </td>\\n</tr>\\n\";

            }

        }

            

                

    }


    if (!$error)

    {


         // if the parser got to this point, it means everything required was filled in

         // and the values were valid ones. so do whatever you want to do here and then exit the script


         exit();

    }




?>


<html>

<body>

<form action=\"
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $PHP_SELF; ?>
\" method=\"post\" name=\"submit_form\">

<table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#000000\" width=\"80%\">

<tr>

<td>

<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" bgcolor=\"#CACACA\" width=\"100%\">

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php

foreach ($options AS $number => $array)

{


     // just delete $number if you don\'t want it to be displayed. But let the <td> intact

    echo $error[$number];

    echo \"<tr>\\n <td valign=\\\"top\\\" width=\\\"1%\\\">\\n\\t$number.\\n </td>\\n\";

    echo \" <td align=\\\"left\\\" valign=\\\"top\\\">\\n\\t$array[question]\\n </td>\\n\";



    if ($array[type] == \"radio\")

    {


        echo \" <td align=\\\"left\\\">\\n\\t\";

        $count = 1;

        foreach ($array[options] AS $option)

        {


            if ($radio[$number] == $count)

            {


                $check = \" checked\";

            }


            else

            {

                $check = \"\";

            }


            echo \"<input type=\\\"radio\\\" name=\\\"radio[$number]\\\" value=\\\"$count\\\"$check>$option $array[break]\\n\";

            $count++;

        }


        echo \" </td>\\n\";

    }


    

    elseif ($array[type] == \"check\")

    {


        echo \" <td align=\\\"left\\\">\\n\\t\";

        $count = 1;

        foreach ($array[options] AS $option)

        {


            if ($checkbox[$number][$count] == \"on\")

            {


                $check = \" checked\";

            }


            else

            {

                $check = \" \";

            }


            echo \"<input type=\\\"checkbox\\\" name=\\\"checkbox[$number][$count]\\\"$check>$option $array[break]\\n\";

            $count++;

            

        }


        echo \" </td>\\n\";

    }


    elseif ($array[type] == \"text\")

    {


        echo \" <td align=\\\"left\\\">\\n\\t<input type=\\\"text\\\" name=\\\"text[$number]\\\" value=\\\"$text[$number]\\\" size=\\\"$array[size]\\\">\\n </td>\\n\";

    }

}


?>


</table>

</td>

</tr>

<tr>

<td>

<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" bgcolor=\"#CACACA\" width=\"100%\">

<tr>

<td align=\"center\" width=\"50%\">

<input type=\"submit\" value=\"Submit Form\">

</td>

<td align=\"center\" width=\"50%\">

<input type=\"reset\" value=\"Reset Form\">

</td>

</tr>

</table>

</td>

</tr>

</table>

<input type=\"hidden\" name=\"action\" value=\"sent\">

</form>

</body>

</html>
 

12/02/2004 18:10:00
Quote Anchor link
aan johan,
bedoeling is om de verstuurde gegevens van een formulier in een access database te importeren hier op een lokale pc, daarom dacht ik aan een bijvoegsel in een txt bestand......
 

13/02/2004 08:10:00
Quote Anchor link
Quote:
wat wil je dan precies verzonden hebben, Nansjepansje(:S)

en wat is jouw vraag nouw pcies Patrick??


bedoeling is om een form te versturen als email met de ingevulde gegens als txt bestand zodat ik de gegevens lokaal kan importeren in een ms accesss database
 

13/02/2004 12:14:00
Quote Anchor link
Hoi Patrick,

dat is ook wat ik nodig heb. De gegevens worden nu heel makkelijk naar je e-mail verzonden.
Hieronder is ene voorbeeld van zo'n mailtje
Alle gegevens moeten hier namelijk ook in access terecht komen ;)


Name,kees
E-Mailadress,[email protected]
Vraag 3,1
Vraag 4,3
Vraag 5,4
Vraag 6,3
Vraag 7,3
Vraag 8,4
Vraag 9,3
Vraag 10,4
Vraag 11,1
Vraag 12,5
Vraag 13,2
Vraag 14,2
Vraag 15,1
Vraag 16,3
Vraag 17,2
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.