Hulp gevraagd voor het verzenden van een form
Ik heb een form gemaakt in html met daarachter de php script. De bedoeling is dat ik deze in mijn mailbox krijg.Ik heb een beetje van alles geprobeerd en krijg het niet goed.de form wordt niet verzonden.Kan mij aub iemand mij hiermee helpen.
Hieronder vind u de code
HTML:
<html>
<head>
</head>
<body>
<fieldset><legend>Sollicitatie</span></legend>
<!--begin:notice message block-->
<div id="note"></div>
<!--begin:notice message block-->
<form id="ajax-contact-form" method="post" ENCTYPE="multipart/form-data" action="index.php" action="javascript:alert('success!');">
<center><p><font color="red">* required fields</font></p></center>
<label>Function</label>
<select name="Function">
<option value="Worker">Worker</option>
<option value="Handy Man">Handy Man</option>
<option value="Cleaning lady/Cleaner">Cleaning lady/Cleaner</option>
<option value="Site leader for renovation works">Site leader for renovation works</option>
<option value="Administrative employee">Administrative employee</option>
<option value="Crane driver">Crane driver</option>
<option value="Room maids">Room maids</option>
<option value="Sales Representatives">Sales Representatives</option>
</select><br />
<label>Name <font color="red">*</font></label><input class="required inpt" type="text" name="name" value="" /><br />
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female<br />
<label>Address</label><font color="red">*</font><input type="text" name="Address" value="" /><br />
<label>Code Postal<font color="red">*</font></label><input class="required inpt" type="text" name="Code Postal" value="" /><br />
<label>City<font color="red">*</font></label><input class="required inpt" type="text" name="city" value="" /><br />
<label>Phone <font color="red">*</font></label><input class="required inpt" type="text" name="phone" value="" /><br />
<label>E-Mail<font color="red">*</font></label><input class="required inpt" type="text" name="email" value="" /><br />
<label>Driving license</label><font color="red">*</font><input class="required input type="text" name="Driving license" value="" /><br />
<label>Experiance</label><input class="required input type="text" name="Experiance" value="" /><br />
<label>Nationality</label><font color="red">*</font><input class="required input type="text" name="Nationality" value="" /><br />
<label>Languages</label><font color="red">*</font><input class="required input type="text" name="Languages" value="" /><br />
Curriculum Vitae <INPUT TYPE=FILE NAME="upfile"><BR>
<INPUT TYPE=SUBMIT VALUE="Submit">
</form>
</body>
</html>
PHP
Code (php)
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
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
<?php
// Receiving variables
@$Function = addslashes($_POST['Function']);
@$name = addslashes($_POST['name']);
@$sex = addslashes($_POST['sex']);
@$Address = addslashes($_POST['Address']);
@$Code_Postal = addslashes($_POST['Code_Postal']);
@$city = addslashes($_POST['city']);
@$phone = addslashes($_POST['phone']);
@$email = addslashes($_POST['email']);
@$Driving_license = addslashes($_POST['Driving_license']);
@$Experiance = addslashes($_POST['Experiance']);
@$Nationality = addslashes($_POST['Nationality']);
@$Languages = addslashes($_POST['Languages']);
@$upfile_Name = $_FILES['upfile']['name'];
@$upfile_Size = $_FILES['upfile']['size'];
@$upfile_Temp = $_FILES['upfile']['tmp_name'];
@$upfile_Mime_Type = $_FILES['upfile']['type'];
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
// Validation
if ( strcasecmp($sex,"male") != 0 && strcasecmp($sex,"female") != 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid sex</font></p>");
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}
if( $upfile_Size == 0)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
if( $upfile_Size >50000000)
{
//delete file
unlink($upfile_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
if( $upfile_Mime_Type != "image/gif" AND $upfile_Mime_Type != "image/pjpeg" AND $upfile_Mime_Type != "image/jpeg" AND $upfile_Mime_Type != "image/png" AND $upfile_Mime_Type != "image/tiff" AND $upfile_Mime_Type != "text/" )
{
unlink($upfile_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
$uploadFile = $upfile_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $upfile_Temp , $uploadFile);
chmod($uploadFile, 0644);
$upfile_URL = "http://www.orisma.com.tr/uplfile/".$upfile_Name ;
//Sending Email to form owner
$pfw_header = "From: $email\n"
. "Reply-To: $email\n";
$pfw_subject = "Curriculum Vitae";
$pfw_email_to = "[email protected]";
$pfw_message = "Function: $Function\n"
. "name: $name\n"
. "sex: $sex\n"
. "Address: $Address\n"
. "Code_Postal: $Code_Postal\n"
. "city: $city\n"
. "phone: $phone\n"
. "email: $email\n"
. "Driving_license: $Driving_license\n"
. "Experiance: $Experiance\n"
. "Nationality: $Nationality\n"
. "Languages: $Languages\n"
. "upfile: $upfile_URL\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Thank you, we have received your message</font></p>");
?>
// Receiving variables
@$Function = addslashes($_POST['Function']);
@$name = addslashes($_POST['name']);
@$sex = addslashes($_POST['sex']);
@$Address = addslashes($_POST['Address']);
@$Code_Postal = addslashes($_POST['Code_Postal']);
@$city = addslashes($_POST['city']);
@$phone = addslashes($_POST['phone']);
@$email = addslashes($_POST['email']);
@$Driving_license = addslashes($_POST['Driving_license']);
@$Experiance = addslashes($_POST['Experiance']);
@$Nationality = addslashes($_POST['Nationality']);
@$Languages = addslashes($_POST['Languages']);
@$upfile_Name = $_FILES['upfile']['name'];
@$upfile_Size = $_FILES['upfile']['size'];
@$upfile_Temp = $_FILES['upfile']['tmp_name'];
@$upfile_Mime_Type = $_FILES['upfile']['type'];
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
// Validation
if ( strcasecmp($sex,"male") != 0 && strcasecmp($sex,"female") != 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid sex</font></p>");
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}
if( $upfile_Size == 0)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
if( $upfile_Size >50000000)
{
//delete file
unlink($upfile_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
if( $upfile_Mime_Type != "image/gif" AND $upfile_Mime_Type != "image/pjpeg" AND $upfile_Mime_Type != "image/jpeg" AND $upfile_Mime_Type != "image/png" AND $upfile_Mime_Type != "image/tiff" AND $upfile_Mime_Type != "text/" )
{
unlink($upfile_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
$uploadFile = $upfile_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $upfile_Temp , $uploadFile);
chmod($uploadFile, 0644);
$upfile_URL = "http://www.orisma.com.tr/uplfile/".$upfile_Name ;
//Sending Email to form owner
$pfw_header = "From: $email\n"
. "Reply-To: $email\n";
$pfw_subject = "Curriculum Vitae";
$pfw_email_to = "[email protected]";
$pfw_message = "Function: $Function\n"
. "name: $name\n"
. "sex: $sex\n"
. "Address: $Address\n"
. "Code_Postal: $Code_Postal\n"
. "city: $city\n"
. "phone: $phone\n"
. "email: $email\n"
. "Driving_license: $Driving_license\n"
. "Experiance: $Experiance\n"
. "Nationality: $Nationality\n"
. "Languages: $Languages\n"
. "upfile: $upfile_URL\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Thank you, we have received your message</font></p>");
?>
Tja en welke moet ie nou hebben? Er kan maar één action zijn.
Draait er wel een mailserver op de server waar je vanaf wil mailen :)?
Verder zijn dit je 2 nieuwe beste vrienden :
edit 2:
Als je een @ voor je mailfunctie zet is 1 ding zeker. Je zal nooit zien wat er mis gaat :)
Gewijzigd op 15/02/2012 12:52:09 door Jacco Engel
Maar ik dacht dat ik misschien wel een fout heb zitten in mijn php
Toevoeging op 15/02/2012 12:56:36:
Haal al die @-jes weg.
Zet error reporting aan.
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
// rest
?>
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
// rest
?>
en wat moet ik dan in de plaats gaan gebruiken van ereg?
preg_match :)
Fouad El Amrani op 15/02/2012 13:00:05:
en wat moet ik dan in de plaats gaan gebruiken van ereg?
Op php.net kijken.
Van php.net:
Note:
preg_match(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to ereg().
is het dan juist voldoende om ereg te vervangen door preg_match() of moet heel de regel aangepast worden?
- SanThe - op 15/02/2012 13:03:29:
Op php.net kijken.
Fouad El Amrani op 15/02/2012 13:00:05:
en wat moet ik dan in de plaats gaan gebruiken van ereg?
Op php.net kijken.
Kijk op php.net voor uitleg.
heb op php.net gekeken en heb geen antwoord op mijn vraag,het zou wel aan mij liggen :-) maar kunnen jullie mij aub verder helpen.
Gewijzigd op 15/02/2012 20:15:49 door Reshad F
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Normaal zou PHP dan iets zeggen van 'Function ereg is deprecated blabla' wat dus nu niet gebeurt.
Zet je error reporting aan, haal de @jes weg want die zorgen er juist voor dat de error die mogelijk wordt gegenereerd genegeerd wordt (Dat wist je misschien al). Bekijk het resultaat en drop het hier :)
de code ziet er nu als volgt uit:
<fieldset><legend>[email protected]</span></legend>
<!--begin:notice message block-->
<div id="note"></div>
<!--begin:notice message block-->
<form id="ajax-contact-form" method="post" ENCTYPE="multipart/form-data" action="index.php" >
<center><p><font color="red">* required fields</font></p></center>
<label>Function</label>
<select name="Function">
<option value="Worker">Worker</option>
<option value="Handy Man">Handy Man</option>
<option value="Cleaning lady/Cleaner">Cleaning lady/Cleaner</option>
<option value="Site leader for renovation works">Site leader for renovation works</option>
<option value="Administrative employee">Administrative employee</option>
<option value="Crane driver">Crane driver</option>
<option value="Room maids">Room maids</option>
<option value="Sales Representatives">Sales Representatives</option>
</select><br />
<label>Name <font color="red">*</font></label><input class="required inpt" type="text" name="name" value="" /><br />
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female<br />
<label>Address</label><font color="red">*</font><input type="text" name="Address" value="" /><br />
<label>Code Postal<font color="red">*</font></label><input class="required inpt" type="text" name="Code Postal" value="" /><br />
<label>City<font color="red">*</font></label><input class="required inpt" type="text" name="city" value="" /><br />
<label>Phone <font color="red">*</font></label><input class="required inpt" type="text" name="phone" value="" /><br />
<label>E-Mail<font color="red">*</font></label><input class="required inpt" type="text" name="email" value="" /><br />
<label>Driving license</label><font color="red">*</font><input class="required input type="text" name="Driving license" value="" /><br />
<label>Experiance</label><input class="required input type="text" name="Experiance" value="" /><br />
<label>Nationality</label><font color="red">*</font><input class="required input type="text" name="Nationality" value="" /><br />
<label>Languages</label><font color="red">*</font><input class="required input type="text" name="Languages" value="" /><br />
Curriculum Vitae <INPUT TYPE=FILE NAME="upfile"><BR>
<INPUT TYPE=SUBMIT VALUE="Submit">
</form>
Code (php)
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
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
<?php
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
// rest
// Receiving variables
$Function = addslashes($_POST['Function']);
$name = addslashes($_POST['name']);
$sex = addslashes($_POST['sex']);
$Address = addslashes($_POST['Address']);
$Code_Postal = addslashes($_POST['Code_Postal']);
$city = addslashes($_POST['city']);
$phone = addslashes($_POST['phone']);
$email = addslashes($_POST['email']);
$Driving_license = addslashes($_POST['Driving_license']);
$Experiance = addslashes($_POST['Experiance']);
$Nationality = addslashes($_POST['Nationality']);
$Languages = addslashes($_POST['Languages']);
$upfile_Name = $_FILES['upfile']['name'];
$upfile_Size = $_FILES['upfile']['size'];
$upfile_Temp = $_FILES['upfile']['tmp_name'];
$upfile_Mime_Type = $_FILES['upfile']['type'];
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
// Validation
if ( strcasecmp($sex,"male") != 0 && strcasecmp($sex,"female") != 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid sex</font></p>");
}
if (! preg_match('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}
if( $upfile_Size == 0)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
if( $upfile_Size >50000000)
{
//delete file
unlink($upfile_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
if( $upfile_Mime_Type != "image/gif" AND $upfile_Mime_Type != "image/pjpeg" AND $upfile_Mime_Type != "image/jpeg" AND $upfile_Mime_Type != "image/png" AND $upfile_Mime_Type != "image/tiff" AND $upfile_Mime_Type != "text/" )
{
unlink($upfile_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
$uploadFile = $upfile_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $upfile_Temp , $uploadFile);
chmod($uploadFile, 0644);
$upfile_URL = "http://www.orisma.com.tr/uplfile/".$upfile_Name ;
//Sending Email to form owner
$pfw_header = "From: $email\n"
. "Reply-To: $email\n";
$pfw_subject = "Curriculum Vitae";
$pfw_email_to = "[email protected]";
$pfw_message = "Function: $Function\n"
. "name: $name\n"
. "sex: $sex\n"
. "Address: $Address\n"
. "Code_Postal: $Code_Postal\n"
. "city: $city\n"
. "phone: $phone\n"
. "email: $email\n"
. "Driving_license: $Driving_license\n"
. "Experiance: $Experiance\n"
. "Nationality: $Nationality\n"
. "Languages: $Languages\n"
. "upfile: $upfile_URL\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Thank you, we have received your message</font></p>");
?>
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
// rest
// Receiving variables
$Function = addslashes($_POST['Function']);
$name = addslashes($_POST['name']);
$sex = addslashes($_POST['sex']);
$Address = addslashes($_POST['Address']);
$Code_Postal = addslashes($_POST['Code_Postal']);
$city = addslashes($_POST['city']);
$phone = addslashes($_POST['phone']);
$email = addslashes($_POST['email']);
$Driving_license = addslashes($_POST['Driving_license']);
$Experiance = addslashes($_POST['Experiance']);
$Nationality = addslashes($_POST['Nationality']);
$Languages = addslashes($_POST['Languages']);
$upfile_Name = $_FILES['upfile']['name'];
$upfile_Size = $_FILES['upfile']['size'];
$upfile_Temp = $_FILES['upfile']['tmp_name'];
$upfile_Mime_Type = $_FILES['upfile']['type'];
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
// Validation
if ( strcasecmp($sex,"male") != 0 && strcasecmp($sex,"female") != 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid sex</font></p>");
}
if (! preg_match('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}
if( $upfile_Size == 0)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
if( $upfile_Size >50000000)
{
//delete file
unlink($upfile_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
if( $upfile_Mime_Type != "image/gif" AND $upfile_Mime_Type != "image/pjpeg" AND $upfile_Mime_Type != "image/jpeg" AND $upfile_Mime_Type != "image/png" AND $upfile_Mime_Type != "image/tiff" AND $upfile_Mime_Type != "text/" )
{
unlink($upfile_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upfile</font></p>");
}
$uploadFile = $upfile_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $upfile_Temp , $uploadFile);
chmod($uploadFile, 0644);
$upfile_URL = "http://www.orisma.com.tr/uplfile/".$upfile_Name ;
//Sending Email to form owner
$pfw_header = "From: $email\n"
. "Reply-To: $email\n";
$pfw_subject = "Curriculum Vitae";
$pfw_email_to = "[email protected]";
$pfw_message = "Function: $Function\n"
. "name: $name\n"
. "sex: $sex\n"
. "Address: $Address\n"
. "Code_Postal: $Code_Postal\n"
. "city: $city\n"
. "phone: $phone\n"
. "email: $email\n"
. "Driving_license: $Driving_license\n"
. "Experiance: $Experiance\n"
. "Nationality: $Nationality\n"
. "Languages: $Languages\n"
. "upfile: $upfile_URL\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Thank you, we have received your message</font></p>");
?>
Heel mooi, maar wat kwam er uit?
wat heb je voor foutmeldingen? Post die hier even :)
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
en dit gebeurt alleen met preg_match ? en als je ereg erin hebt dan doet hij het wel of krijg je dit dan nog steeds? want een 404 error krijg je meestal als iets niet wordt gevondenn ...