Form script error

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Avinash Soekha

Avinash Soekha

19/12/2011 08:19:33
Quote Anchor link
Beste,

Voor mijn website www.carriere-makers.nl is de onderstaande script geschreven.
Echter deze werk niet helemaal naar behoren. Je krijt een error bericht als iemand zich aanmeld en geen nieuwsbrief wilt ontvangen.
Weet iemand waar dit aan kan liggen?



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
<?php
if(isset($_POST['email'])) {
    
    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "[email protected]";
    $email_subject = "Info aanvraag Carriere-Makers";
    
    
    function
died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }

    
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !
isset($_POST['last_name']) ||
        !
isset($_POST['email']) ||
        !
isset($_POST['telephone']) ||
        !
isset($_POST['newsletter'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
    }

    
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
    $newsletter = $_POST['newsletter']; // required
    
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }

    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }

  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }

  if(strlen($newsletter) < 2) {
    $error_message .= 'The newsletter you entered do not appear to be valid.<br />';
  }

  if(strlen($error_message) > 0) {
    died($error_message);
  }

    $email_message = "Informatie aanvraag van:\n\n";
    
    function
clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }

    
    $email_message .= "Voornaam: ".clean_string($first_name)."\n";
    $email_message .= "Achternaam: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Telefoon: ".clean_string($telephone)."\n";
    $email_message .= "Mailing: ".clean_string($newsletter)."\n";
    
    
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@
mail($email_to, $email_subject, $email_message, $headers);


$down1 = "Presentatie Carriere-Makers";
            $downmail1 = $email_from;
            $onderwerp1 = "Informatieve aanvraag Carriere-Makers.nl";
            $headers1   = "From: ".$down1." <".$downmail1.">\r\n";
            $headers1  .= "MIME-Version: 1.0\n";  
            $headers1  .= "Content-Type: text/html;\n";  
               $headers1  .= "Content-Transfer-Encoding: 7bit";

$message1 = "
<html>
<head>
<title>Untitled-1</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<style type='text/css'>
<!--
body {
    background-image: url(http://www.carriere-makers.nl/images/bg.jpg);
}
.style1 {
    font-family: Arial;
    font-size: 16px;
}
-->
</style></head>
<body bgcolor='#FFFFFF' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
<div align='center'>
  <table id='Table_01' width='600' height='480' border='0' cellpadding='0' cellspacing='0'>
    <tr>
      <td colspan='3'>
        <img src='http://www.carriere-makers.nl/images/email_01.png' width='600' height='288' alt=''></td>
    </tr>
    <tr>
      <td width='25' height='160' bgcolor='#FFFFFF'>&nbsp;</td>
      <td width='552' bgcolor='#FFFFFF'><p class='style1'><br>
        Beste $first_name $last_name,
                <br>
      </p>
        <p class='style1'>Bedankt voor het bezoeken van onze website enkele ogenblikken geleden en het uiten van uw belangstelling in WorldVentures!</p>
        <p class='style1'>Het is handig om deze e-mail op te slaan voor toekomstige gebruik, want het bevat nuttige informatie voor het herzien van onze website in de toekomst.</p>
        <p class='style1'>Mocht u vragen hebben, aarzel dan niet en neem gerust contact met ons op. <br>
        Hieronder vind u onze contactgegevens.</p>
        <p class='style1'>Bent u klaar voor de volgende stap? Bekijk dan de informatieve presentatie.</p>
        <p class='style1'>Nogmaals bedankt en wij kijken ernaar uit u binnekort te spreken.<br>
        </p>
        <p class='style1'>Met vriendelijke groet,</p>
        <p class='style1'>Avinash Soekha<br>
          06 26 46 48 18<br>
        [email protected]</p>
        <p align='center' class='style1'><a href='http://www.carriere-makers.nl/presentatie'><img src='http://www.carriere-makers.nl/images/index_17.png' alt='Bekijk presentatie' width='249' height='48'></a></p></td>
        <td width='23' height='160' bgcolor='#FFFFFF'>&nbsp;</td>
      </tr>
    <tr>
      <td colspan='3'>
        <img src='http://www.carriere-makers.nl/images/email_05.png' width='600' height='32' alt=''></td>
    </tr>
  </table>
</div>
</body>
</html>
"
;

mail($downmail1, $onderwerp1, $message1, $headers1);
            
             ?>



?>

<html>
<head>
<title>Carriere Makers</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-image: url(images/bg.jpg);
background-repeat: repeat-x;
}
.style1 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 13px;
font-weight: bold;
}
.style3 {
font-weight: bold;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 9px;
color: #FFFFFF;
}
.style6 {font-size: 9px; color: #FFFFFF; }
.style29 {
font-size: 18px;
font-family: Arial;
font-weight: bold;
}

-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center">
<table id="Table_01" width="1024" height="1011" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="8">
<img src="images/index_01.png" width="1024" height="108" alt=""></td>
</tr>
<tr>
<td rowspan="6">
<img src="images/index_02.png" width="104" height="902" alt=""></td>
<td colspan="3" rowspan="3">
<img src="images/index_03.png" width="588" height="459" alt=""></td>
<td colspan="3">
<img src="images/index_04.png" width="264" height="137" alt=""></td>
<td rowspan="6">
<img src="images/index_05.png" width="68" height="902" alt=""></td>
</tr>
<tr>
<td height="197" colspan="2" background="images/index_06.png"><div align="center"><span class="style1">Welkom bij Carriere Makers!<br>
<span class="style6">-</span><br>
Wij brengen mensen samen<br>
die meer uit het leven willen halen dan een baan van 9-5. <br>
Wij leren jou geld verdienen <br>
door te leven en te genieten.<br>
<span class="style6">-</span><br>
Ga vaker op reis, doe de<br>
dingen die je echt graag wilt doen, en verdien geld!<br>
</span><span class="style3">-</span><span class="style1"><br>
Verander je leven nu!</span></div></td>
<td rowspan="2">
<img src="images/index_07.png" width="43" height="322" alt=""></td>
</tr>
<tr>
<td>
<img src="images/index_08.png" width="220" height="125" alt=""></td>
<td>
<img src="images/index_09.png" width="1" height="125" alt=""></td>
</tr>
<tr>
<td height="321" colspan="6" valign="middle" background="images/index_10.png"><table width="100%" border="0" align="center">
<tr>
<td>&nbsp;</td>
<td><div align="center" class="style29">
<p>Bedankt voor uw aanvraag. </p>
<p>U ontvangt direct onze informatieve presentatie via de e-mail.</p>
<p>Veel plezier!</p>
</div></td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td rowspan="2">
<img src="images/index_11.png" width="298" height="122" alt=""></td>
<td><img src="images/index_16.png" width="253" height="46"></td>
<td colspan="4" rowspan="2">
<img src="images/index_13.png" width="301" height="122" alt=""></td>
</tr>
<tr>
<td>
<img src="images/index_14.png" width="253" height="76" alt=""></td>
</tr>
<tr>
<td>
<img src="images/spacer.gif" width="104" height="1" alt=""></td>
<td>
<img src="images/spacer.gif" width="298" height="1" alt=""></td>
<td>
<img src="images/spacer.gif" width="253" height="1" alt=""></td>
<td>
<img src="images/spacer.gif" width="37" height="1" alt=""></td>
<td>
<img src="images/spacer.gif" width="220" height="1" alt=""></td>
<td>
<img src="images/spacer.gif" width="1" height="1" alt=""></td>
<td>
<img src="images/spacer.gif" width="43" height="1" alt=""></td>
<td>
<img src="images/spacer.gif" width="68" height="1" alt=""></td>
</tr>
</table>
</div>
</body>
</html>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
}
?>
 
PHP hulp

PHP hulp

25/11/2024 00:39:47
 
- Ariën  -
Beheerder

- Ariën -

19/12/2011 08:40:41
Quote Anchor link
Welk error bericht? En pas je code eens aan naar relevante code.
 
Avinash Soekha

Avinash Soekha

19/12/2011 10:10:44
Quote Anchor link
Krijg de volgende error:

We are very sorry, but there were error(s) found with the form you submitted. These errors appear below.

We are sorry, but there appears to be a problem with the form you submitted.

Please go back and fix these errors.


De code is gemaakt voor mij, maar de maker is spoorloos. Wat betreft de relevante code, als je mij hiermee kunt helpen graag.
 
- Ariën  -
Beheerder

- Ariën -

19/12/2011 10:31:07
Quote Anchor link
Wil best even kijken. Maar kort eerst je code even in. +/- 300 zijn best overdreven.
 
Kitty N

kitty N

19/12/2011 10:33:48
Quote Anchor link
Ik vermoed dat het hiermee te maken heeft:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
<?php
// validation expected data exists
    if(!isset($_POST['first_name']) ||
        !
isset($_POST['last_name']) ||
        !
isset($_POST['email']) ||
        !
isset($_POST['telephone']) ||
        !
isset($_POST['newsletter'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
    }

?>


Het formulier wat verstuurd wordt, zie ik in je code niet te staan. Ook best kans dat ik er overheen kijk?
Gewijzigd op 19/12/2011 12:55:01 door kitty N
 
- Ariën  -
Beheerder

- Ariën -

19/12/2011 10:38:18
Quote Anchor link
jep, die velden bestaan niet.

Check ook even je HTML-code. Deze rammelt behoorlijk, en je HTML structuur ontbreekt ook.


Zou je aub je code nog even willen inkorten?
Gewijzigd op 19/12/2011 10:47:28 door - Ariën -
 
Avinash Soekha

Avinash Soekha

19/12/2011 12:45:43
Quote Anchor link
Beste aar,

Ik heb er wijnig tot geen verstand van, ik snap het een beetje maar script schrijven gaat mij te ver.
Ik zou het graag inorde willen laten maken, eventueel tegen een betaling.
 
- Ariën  -
Beheerder

- Ariën -

19/12/2011 13:46:46
Quote Anchor link
Eigenlijk zou je zoiets in het vacature-forum moeten plaaten ;-)
Maar goed, ik wil best eens kijken komende dagen, wat ik voor je kan doen...

PM me anders even.
Gewijzigd op 19/12/2011 13:47:26 door - Ariën -
 
Avinash Soekha

Avinash Soekha

19/12/2011 19:12:35
Quote Anchor link
Dit is het orgineel HTML:

<form name="contactform" method="post" action="send_form_email.php"><table width="450px"></tr><tr> <td valign="top"> <label for="first_name">First Name *</label> </td> <td valign="top"> <input type="text" name="first_name" maxlength="50" size="30"> </td></tr> <tr> <td valign="top""> <label for="last_name">Last Name *</label> </td> <td valign="top"> <input type="text" name="last_name" maxlength="50" size="30"> </td></tr><tr> <td valign="top"> <label for="email">Email Address *</label> </td> <td valign="top"> <input type="text" name="email" maxlength="80" size="30"> </td> </tr><tr> <td valign="top"> <label for="telephone">Telephone Number</label> </td> <td valign="top"> <input type="text" name="telephone" maxlength="30" size="30"> </td></tr><tr> <td valign="top"> <label for="comments">Comments *</label> </td> <td valign="top"> <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea> </td> </tr><tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"> <a href="/email_form.php">Email Form</a> </td></tr></table></form>

En dit de verwerk pagina orgineel:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?phpif(isset($_POST['email'])) {         // EDIT THE 2 LINES BELOW AS REQUIRED    $email_to = "[email protected]";    $email_subject = "Your email subject line";              function died($error) {        // your error code can go here        echo "We are very sorry, but there were error(s) found with the form you submitted. ";        echo "These errors appear below.<br /><br />";        echo $error."<br /><br />";        echo "Please go back and fix these errors.<br /><br />";        die();    }         // validation expected data exists    if(!isset($_POST['first_name']) ||        !isset($_POST['last_name']) ||        !isset($_POST['email']) ||        !isset($_POST['telephone']) ||        !isset($_POST['comments'])) {        died('We are sorry, but there appears to be a problem with the form you submitted.');           }         $first_name = $_POST['first_name']; // required    $last_name = $_POST['last_name']; // required    $email_from = $_POST['email']; // required    $telephone = $_POST['telephone']; // not required    $comments = $_POST['comments']; // required         $error_message = "";    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';  if(!preg_match($email_exp,$email_from)) {    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';  }    $string_exp = "/^[A-Za-z .'-]+$/";  if(!preg_match($string_exp,$first_name)) {    $error_message .= 'The First Name you entered does not appear to be valid.<br />';  }  if(!preg_match($string_exp,$last_name)) {    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';  }  if(strlen($comments) < 2) {    $error_message .= 'The Comments you entered do not appear to be valid.<br />';  }  if(strlen($error_message) > 0) {    died($error_message);  }    $email_message = "Form details below.\n\n";         function clean_string($string) {      $bad = array("content-type","bcc:","to:","cc:","href");      return str_replace($bad,"",$string);    }         $email_message .= "First Name: ".clean_string($first_name)."\n";    $email_message .= "Last Name: ".clean_string($last_name)."\n";    $email_message .= "Email: ".clean_string($email_from)."\n";    $email_message .= "Telephone: ".clean_string($telephone)."\n";    $email_message .= "Comments: ".clean_string($comments)."\n";          // create email headers$headers = 'From: '.$email_from."\r\n".'Reply-To: '.$email_from."\r\n" .'X-Mailer: PHP/' . phpversion();@mail($email_to, $email_subject, $email_message, $headers);  ?>
<!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon.
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php}?>



Echter heeft de maker de $comments veranderd naar een Checkbox, ik denk dat hier iets niet goed gaat. Volgens mij is dit zo opgelost?



Toevoeging op 19/12/2011 19:14:23:

Nogmaals de php code:

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
<?php
if(isset($_POST['email'])) {
    
    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "[email protected]";
    $email_subject = "Your email subject line";
    
    
    function
died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }

    
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !
isset($_POST['last_name']) ||
        !
isset($_POST['email']) ||
        !
isset($_POST['telephone']) ||
        !
isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
    }

    
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // required
    
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }

    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }

  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }

  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }

  if(strlen($error_message) > 0) {
    died($error_message);
  }

    $email_message = "Form details below.\n\n";
    
    function
clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }

    
    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Telephone: ".clean_string($telephone)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";
    
    
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@
mail($email_to, $email_subject, $email_message, $headers);  
?>


<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
}
?>
 
Ger van Steenderen
Tutorial mod

Ger van Steenderen

19/12/2011 19:47:18
Quote Anchor link
Er wordt een controle uitgevoerd of de variable $_POST['comments'] bestaat, echter als de ccheckbox niet is aangevinkt wordt de waarde ervan niet met het formulier meegestuurd.
 
- Ariën  -
Beheerder

- Ariën -

19/12/2011 19:48:12
Quote Anchor link
En toch blijft het een brak script. Waarom zou je bij een foute input-validatie het script met die() willen laten stoppen?
 



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.