Javascript-formulier omzetten naar php-formulier

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

24/09/2004 21:26:00
Quote Anchor link
Ik zou graag een mailform willen omzetten naar php met een bedanking achteraf. Heb al op verschillende manieren geprobeerd, maar door mijn zeer beperkte kennis van php is dit telkens mislukt. Is er iemand die me kan helpen?

Onderaan zie je eerst het javascriptformulier. Vervolgens het php-formulier (of toch een poging)


JAVASCRIPT-FORMULIER:
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
118
<html>
<head>
<title>Hoorn.be - hoornpool</title>
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' U moet hier een emailadres invullen.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' Dit moet een nummer zijn.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' Dit moet een nummer zijn tussen '+min+' en '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is verplicht.\n'; }
  } if (errors) alert('De volgende velden zijn verplicht:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body bgcolor="#FFF3C4" text="#000000" onLoad="MM_validateForm('naam:','','R','emailadres:','','RisEmail','geboortedag:','','RinRange1:31','geboortemaand:','','RinRange1:12','geboortedjaar:','','RinRange1900:2000','woonplaats:','','R','provincie:','','R','telefoon:','','R','kilometers:','','NisNum');return document.MM_returnValue" link="#7E5429" vlink="#7E5429" alink="#7E5429">
<form name="form1" method="post" action="mailto:[email protected]" enctype="text/plain">
  <p align="center"><font face="Helvetica, sans-serif, Arial" size="2" color="#7E5429">Indien
    problemen met doorsturen: mail je gegevens door naar <a href="mailto:[email protected]?subject=gegevens%20poolformulier" target="_blank">[email protected]</a></font></p>
  <table width="80%" border="0" align="center" bgcolor="#efe3b5">
    <tr valign="top">
      <td width="45%">
        <div align="right"><font face="Helvetica, sans-serif, Arial"><font face="Helvetica, sans-serif, Arial"><font size="3">Naam</font></font></font></div>
      </td>
      <td width="5%"><font face="Helvetica, sans-serif, Arial" size="3"></font></td>
      <td width="50%"><font face="Helvetica, sans-serif, Arial" size="3">
        <input type="text" name="naam:" size="25" onBlur="MM_validateForm('naam:','','R','emailadres:','','R','geboortedag:','','RinRange1:31','geboortemaand:','','RinRange1:12','geboortedjaar:','','RinRange1900:2000','woonplaats:','','R','provincie:','','R','telefoon:','','R','kilometers:','','NisNum');return document.MM_returnValue">
        </font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial"><font face="Helvetica, sans-serif, Arial"><font size="3">Emailadres</font></font></font></div>
      </td>
      <td><font face="Helvetica, sans-serif, Arial" size="3"></font></td>
      <td><font face="Helvetica, sans-serif, Arial" size="3">
        <input type="text" name="emailadres:" size="25">
        </font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial"><font face="Helvetica, sans-serif, Arial"><font size="3">Leeftijd</font></font></font></div>
      </td>
      <td><font face="Helvetica, sans-serif, Arial" size="3"></font></td>
      <td><font face="Helvetica, sans-serif, Arial" size="3">
        <input type="text" name="geboortedag:" size="3" maxlength="2">
        -
        <input type="text" name="geboortemaand:" size="3" maxlength="2">
        -
        <input type="text" name="geboortedjaar:" size="5" maxlength="4">
        <font size="2"> (dd-mm-jjjj)</font></font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial"><font face="Helvetica, sans-serif, Arial"><font size="3">Woonplaats</font></font></font></div>
      </td>
      <td><font face="Helvetica, sans-serif, Arial" size="3"></font></td>
      <td><font face="Helvetica, sans-serif, Arial" size="3">
        <input type="text" name="woonplaats:" size="25">
        </font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial"><font face="Helvetica, sans-serif, Arial"><font size="3"><font face="Helvetica, sans-serif, Arial"><font size="3"><font size="3"><font face="Helvetica, sans-serif, Arial">Provincie</font></font></font></font></font></font></font></div>
      </td>
      <td><font face="Helvetica, sans-serif, Arial" size="3"></font></td>
      <td><font face="Helvetica, sans-serif, Arial" size="3">
        <input type="text" name="provincie:" size="25">
        </font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial"><font size="3"><font size="3"><font face="Helvetica, sans-serif, Arial">Telefoon</font></font></font></font></div>
      </td>
      <td><font face="Helvetica, sans-serif, Arial"></font></td>
      <td><font face="Helvetica, sans-serif, Arial">
        <input type="text" name="telefoon:" size="25">
        </font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial"><font size="3"><font size="3"><font face="Helvetica, sans-serif, Arial">Aantal
          kilometers bereid te reizen</font></font></font></font></div>
      </td>
      <td><font face="Helvetica, sans-serif, Arial"></font></td>
      <td><font face="Helvetica, sans-serif, Arial">
        <input type="text" name="kilometers:" size="25">
        </font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial">Instrument</font></div>
      </td>
      <td>&nbsp;</td>
      <td>
        <input type="radio" name="instrument:" value="hoorn" checked>
        <font face="Helvetica, sans-serif, Arial">hoorn</font><font face="Helvetica, sans-serif, Arial"><br>
        <input type="radio" name="instrument:" value="althoorn">
        althoorn</font></td>
    </tr>
    <tr valign="top">
      <td>



OMVORMEN TOT EEN PHP-FORMULIER:(zie 5 onderstaande codes)


Formulier.htm
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<html>

<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<meta HTTP-EQUIV="Content-Language" CONTENT="nl">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Hoorn.be - hoornpool</title>
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body bgcolor="#FFF3C4">
<font color="#FF8500">
<h1>&nbsp;</h1>
<form METHOD="POST" ACTION="avos/formulier.php" name="Ticket LUMEN PROMmS 2004">
  <table width="80%" bgcolor="#efe3b5" align="center">
    <tr>
      <td ALIGN="right" width="45%"><font face="Helvetica, Arial, serif, Verdana">Voornaam*</font></td>
      <td width="5%">&nbsp; </td>
      <td> <font face="Helvetica, sans-serif, Arial" size="3">
        <input type="text" name="naam" size="25" onBlur="MM_validateForm('naam:','','R');return document.MM_returnValue">
        </font></td>
    </tr>
    <tr>
      <td align="right" height="31" width="45%"><font face="Helvetica, Arial, serif, Verdana">E-mail*</font></td>
      <td width="5%" height="31">&nbsp;</td>
      <td height="31">
        <input type="TEXT" name="Email" size="25">
      </td>
    </tr>
    <tr>
      <td ALIGN="right" width="45%"><font face="Helvetica, Arial, serif, Verdana">Leeftijd</font></td>
      <td width="5%">&nbsp; </td>
      <td>
        <input type="TEXT" name="Leeftijd" size="35">
      </td>
    </tr>
    <tr>
      <td align="right" width="45%"><font face="Helvetica, Arial, serif, Verdana">Woonplaats</font></td>
      <td width="5%">&nbsp;</td>
      <td>
        <input type="TEXT" name="Woonplaats" size="35">
      </td>
    </tr>
    <tr>
      <td ALIGN="right" width="45%"><font face="Helvetica, Arial, serif, Verdana">Provincie</font></td>
      <td width="5%">&nbsp;</td>
      <td>
        <input type="TEXT" name="Provincie" size="35">
      </td>
    </tr>
    <tr>
      <td align="right" width="45%"><font face="Helvetica, Arial, serif, Verdana">Telefoon</font></td>
      <td width="5%">&nbsp; </td>
      <td>
        <input type="TEXT" name="Telefoon" size="25" maxlength="25">
      </td>
    </tr>
    <tr valign="top">
      <td width="45%">
        <div align="right"><font face="Helvetica, sans-serif, Arial"><font size="3"><font size="3"><font face="Helvetica, sans-serif, Arial">Aantal
          kilometers bereid te reizen</font></font></font></font></div>
      </td>
      <td><font face="Helvetica, sans-serif, Arial"></font></td>
      <td><font face="Helvetica, sans-serif, Arial">
        <input type="text" name="kilometers" size="25">
        </font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial">Instrument</font></div>
      </td>
      <td>&nbsp;</td>
      <td>
        <input type="radio" name="instrument:" value="hoorn" checked>
        <font face="Helvetica, sans-serif, Arial">hoorn</font><font face="Helvetica, sans-serif, Arial"><br>
        <input type="radio" name="instrument:" value="althoorn">
        althoorn</font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial" size="3">Status</font></div>
      </td>
      <td>&nbsp;</td>
      <td>
        <input type="radio" name="status:" value="amateur">
        <font face="Helvetica, sans-serif, Arial">amateur<br>
        <input type="radio" name="status:" value="semi">
        semi<br>
        <input type="radio" name="status:" value="prof">
        prof </font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial"><font size="3"><font size="3"><font face="Helvetica, sans-serif, Arial">Partij(en)</font></font></font></font></div>
      </td>
      <td>&nbsp;</td>
      <td><font face="Helvetica, sans-serif, Arial">
        <input type="text" name="partij:" size="5">
        </font></td>
    </tr>
    <tr valign="top">
      <td>
        <div align="right"><font face="Helvetica, sans-serif, Arial">Betaald ?</font></div>
      </td>
      <td>&nbsp;</td>
      <td>
        <input type="radio" name="betaald?" value="nee" onClick="MM_validateForm('naam','','R','kilometers','','R');return document.MM_returnValue" checked>
        <font face="Helvetica, sans-serif, Arial"> nee<br>
        <input type="radio" name="betaald?" value="kilometervergoeding">
        alleen kilometervergoeding<br>
        <input type="radio" name="betaald?" value="otk">
        overeen te komen</font><br>
        <input type="radio" name="betaald?" value="bedrag:">
        <input type="text" name="som:">
      </td>
    </tr>
  </table>
  <div align="center">
    <input type="submit" name="Submit2" value="verzenden" onClick="MM_validateForm('naam:','','R','emailadres:','','NisEmail','leeftijd:','','NisNum','woonplaats:','','R','telefoon:','','R');return document.MM_returnValue">
  </div>
</form>
<h5>&nbsp;</h5>
</font>
</body>

</html>



Formulier.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
<?php

$DenL
= "[email protected]" ;
$onderwerp = "Online tickets" ;
$fouturl = "error.htm" ;
$okurl = "ok.htm" ;
$gnkaarturl = "formulier.htm" ;

$naam = $_POST['Naam'] ;
$email = $_POST['Email'] ;
$leeftijd = $_POST['Leeftijd'] ;
$woonplaats = $_POST['Woonplaats'] ;
$provincie = $_POST['Provincie'] ;
$telefoon = $_POST['Telefoon'] ;
$kilometers = $_POST['Kilometers'] ;
$partij = $_POST['Partij'] ;
$som = $_POST['som'] ;

if (empty($email) || empty($voornaam) || empty($naam)) {
    header( "Location: $fouturl" );
    exit ;
}


if (empty($volw) && empty($stud)) {
    header( "Location: $gnkaarturl" );
    exit ;
}


$bericht = "Online tickets besteld door:\n\n" .
           "$$naam\n" .
           "$email\n" .
           "$leeftijd\n" .
           "$woonplaats\n" .
           "$provincie\n" .
           "$telefoon\n" .
           "$kilometers\n" .
           "$partij\n" .
        "$som\n" .
           "verwerking: $verwerken\n" ;

mail($DenL, $onderwerp, $bericht, "From: \"$voornaam $naam\" <$email>\nReply-To: \"$voornaam $naam\" <$email>\nX-Mailer: PHP/phpversion()" );
header( "Location: $okurl" );
exit ;

?>



feedback.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
<?
/*
    CHFEEDBACK.PHP Feedback Form PHP Script Ver 2.02.
    Generated by thesitewizard.com's Feedback Form Wizard.
    Copyright 2000-2004 by Christopher Heng. All rights reserved.
    thesitewizard and thefreecountry are trademarks of Christopher Heng.

    $Id: phpscript.txt 3.3 2004/06/18 11:33:40 chris Exp $

    Get the latest version, free, from:
        http://www.thesitewizard.com/wizards/feedbackform.shtml

    You can contact me at:
        http://www.thesitewizard.com/feedback.php

    LICENCE TERMS
    
    1. You may use this script on your website, with or
    without modifications, free of charge.
    
    2. You may NOT distribute or republish this script,
    whether modified or not. The script is meant for your
    personal use on your website, and can only be
    distributed by the author, Christopher Heng.
    
    3. THE SCRIPT AND ITS DOCUMENTATION ARE PROVIDED
    "AS IS", WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE
    IMPLIED WARRANTY OF MECHANTABILITY OR FITNESS FOR A
    PARTICULAR PURPOSE. YOU AGREE TO BEAR ALL RISKS AND
    LIABILITIES ARISING FROM THE USE OF THE SCRIPT,
    ITS DOCUMENTATION AND THE INFORMATION PROVIDED BY THE
    SCRIPTS AND THE DOCUMENTATION.

    If you cannot agree to any of the above conditions, you
    may not use the script.
    
    Although it is NOT required, I would be most grateful
    if you could also link to thesitewizard.com at:

       http://www.thesitewizard.com/

*/

// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent t



[b]OK.htm[/b]
[
code]<html>

<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<
meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<
meta name="ProgId" content="FrontPage.Editor.Document">
<
title>Bestelling verzonden</title>
<
/head>

<
body bgcolor="#FFF3C4">
<
font color="#FF8500"> <br>
<
/font><br>
<
h2>Bevestiging bestelling</h2>
<
p>Wij hebben uw gegevens goed ontvangen. Binnenkort krijgt u van ons een bevestiging.
  Indien u deze niet ontvangt binnen de 3 werkdagen, zijn er waarschijnlijk ergens
  fouten opgetreden. In dat geval vragen wij u om uw gegevens opnieuw door te
  voeren.<br>
  <
br>
  HHoorn.be dankt u alvast voor uw interesse</p>
<
/body>
<
/html>[/code]


[
b]error.htm[/b]
[
code]<html>

<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<
meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<
meta name="ProgId" content="FrontPage.Editor.Document">
<
title>Bestelling verzonden</title>
<
/head>

<
body bgcolor="#FFF3C4">
<
font color="#FF8500"> <br>
<
br>
<
/font>
<
h2>Bestelling mislukt</h2>
<
p>Uw gegevens zijn niet worden verzonden. Onze excuses hiervoor. Zorg ervoor
  dat u de verplichte velden zeker invult.</p>
<
p>Probeer het nog eens opnieuw</p>
<
/body>
<
/html>[/code]


Dat is het
 
PHP hulp

PHP hulp

23/11/2024 19:03:17
 
Elwin - Fratsloos

Elwin - Fratsloos

24/09/2004 23:19:00
Quote Anchor link
Ja... dat is het. Wie wil?

Elwin
 



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.