Advertisement

06.13.2008 at 12:17AM PDT, ID: 23481980
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

X-Mailer: PHP

Asked by Milcoi in PHP Scripting Language, PHP and Databases

hi, This code below should work but i don't receive any e-mail. even no erro message.
What's wrong?

Start Free Trial
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:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
<?php
//initilize PHP
 
//if($_POST['submit']) //If submit is hit
// de submit kan komen uit de voorpagina of via het complete invulformulier. Vandaar dat er ook nog
// gecontroleerd wordt op de $_POST['action']
if (isset($_POST['submit']) && isset($_POST["action"]) && $_POST["action"]=="doadd") 
{
   
   // controleren of alle velden wel op de juiste manier zijn ingevoerd
   // Hier stellen we een lijst op met verplichte velden die ingevoerd moeten worden
   // eerste is het veld wat er moet komen tweede is de omschrijving zoals die dan weergegeven wordt bij dat veld.
   $verplichtArr = array(
         "naam"          => "De naam", 
         "adres"         => "Het adres",
         "nr"             => "Het nummer",
         "postcode"   => "De postcode",
         "plaats"      => "De plaats",
         "land"         => "Het land",
         "tel"            => "het telefoonnummer",
         "icon"         => "De type locatie",
         "password"   => "Het wachtwoord",
         "email"         => "Het email adres"
         ); 
   
   // hier lopen we dan vervolgens de verschillende verplichte velden door
   foreach($verplichtArr as $veld => $veldnaam){
      if(strlen($_POST[$veld]) < 1){
         $foutje[]= $veldnaam." dient ingevoerd te worden. <br />";
      }
   }
   
   // er is al gecontroleerd of er een wachtwoord is hierboven, maar nu moeten we ook nog zorgen dat de twee
   // versies gelijk zijn.
   if($_POST["password"] != $_POST["password2"]){
      $foutje[] = "De gekozen wachtwoorden komen niet overeen.<br />";
   }
   
   // via een specifieke opmaak controleren we of het email adres wel op de juiste manier is opgebouwd
   if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,5}[mtgvu]?$", $_POST["email"]) ) {
      $foutje[] = "Er dient een correct email adres ingevoerd te worden.</br>";
   }
   
   if(!$foutje){
      // er zijn blijkbaar geen fouten geconstateerd dus we kunnen een en ander invoeren
   
   include_once($_SERVER["DOCUMENT_ROOT"]."/config.php");
   
   //convert all the posts to variables:
   // hierbij zorgen we tevens voor een addslashes, dit zorgt er voor dat je geen problemen krijgt met vreemde tekens
   // dit is veiliger bij het injecteren van gegevens. Wanneer je dit niet doet, kunnen hackers ook zorgen voor foutief
   // gebruik van je formulier.
   foreach($_POST as $key => $value){
      $$key = addslashes($value);
   }
   
   //Insert the values into the correct database with the right fields
  
   $result=MYSQL_QUERY(
         "INSERT INTO clubs  ( 
            `id` , 
            `lat` , 
            `lon` , 
            `naam` , 
            `adres` , 
            `nr` , 
            `postcode` , 
            `plaats` , 
            `provincie` , 
            `land` , 
            `email`  , 
            `tel` , 
            `password` , 
            `url` , 
            `icon`
            ) VALUES (
         'NULL', 
         '".$lat."', 
         '".$lon."', 
         '".$naam."', 
         '".$adres."', 
         '".$nr."', 
         '".$postcode."', 
         '".$plaats."', 
         '".$provincie."', 
         '".$land."', 
         '".$email."', 
         '".$tel."', 
         '".md5($password)."', 
         '".$url."', 
         '".$icon."'
         )"); 
 
    //confirm
 
      $text = "<div id=\"content\">De volgende lokatie is toegevoegd aan de database<br><br><br>";
      $text .= "<b>Naam:</b>&nbsp;$naam<br>";
      $text .= "<b>Adres:</b>&nbsp;$adres<br>";
      $text .= "<b>Nummer:</b>&nbsp;$nr<br>";
      $text .= "<b>Postcode:</b>&nbsp;$postcode<br>";
      $text .= "<b>Plaats:</b>&nbsp;$plaats<br>";
      $text .= "<b>Provincie:</b>&nbsp;$provincie<br>";
      $text .= "<b>Land:</b>&nbsp;$land<br>";
      $text .= "<b>E-mail:</b>&nbsp;$email<br>";
      $text .= "<b>Telefoon:</b>&nbsp;$tel<br>";
      $text .= "<b>Website:</b>&nbsp;$url<br>";
 
      $mailtext = str_replace("<br>","\n",$text);
      $mailtext = strip_tags($mailtext);
      $mailtext .="Wachtwoord:&nbsp;".$password."\n";
 
      $text .= "<b>Bedankt voor het toevoegen van deze lokatie.</b><br><br>";
      $text .= '<a href="RC-plane.php">Klik hier om weer terug te keren naar het overzicht</a></div>'; 
 
      $afzender          = "test.com";
      $afzender_email = "noreply@test.com";
      $ontvanger         = $email;
      $ontvanger_email= $email;
 
      $subject = "Dank voor uw aanmelding";
      $message = $mailtext;
 
      $to                  = $ontvanger." <".$ontvanger_email.">";
      $headers             = "From: ".$afzender." <".$afzender_email."> \n";
      $headers          .=   "X-Mailer: PHP/" . phpversion();
      
      @mail($to, $subject, $message, $headers);
      
 
      include_once("./templateClean.php");
      echo $template;
      exit; // hier een exit omdat je de rest van het formulier toch niet meer wil tonen en een link om terug te gaan naar de voorpagina
   }
 
}
 
// close php so we can put in our code
   // kijken of een van de velden al geset zijn, dan komen we namelijk van de voorpagina en moet het een en ander al klaar gezet worden
 
   if(strlen($_POST["flightclub"]) > 2) {
      $red="checked";
      $_POST["naam"]=$_POST["flightclub"];
   }elseif(strlen($_POST["flight-airport"]) > 2) {
      $green="checked";
      $_POST["naam"]=$_POST["flight-airport"];
   }elseif(strlen($_POST["modelshop"]) >2) {
      $black="checked";
      $_POST["naam"]=$_POST["modelshop"];
   }
   
   // het kan natuurlijk zijn dat er iets fout is gegaan bij de afhandeling, in dat geval is er wellicht al een keuze is gemaakt, in dat
   // geval moeten we ook even zorgen dat deze terug gezet wordt.
   
   if(strlen($_POST["icon"]) > 2){
      $$_POST["icon"]="checked";
      // wat we hier doen is het volgende. Stel er is gekozen voor vliegclub. in dat geval is $_POST["icon"] red. Met de
      // functie hierboven wordt dan het volgende geset $red="selected" Deze selected zorgt ervoor dat deze radiobutton alvast
      // aangevinkt wordt.
      // Omdat je het aanvinken van de radio button ook gebruikte om het adres samen te stellen heb ik dat terug gevoerd naar de 'Go!'
      // button, wanneer je daar op drukt, wordt het adres veld samen gesteld voor google om de lat en lon te bepalen.
   }
   
   /**
   In de tekst heb ik ook iedere keer een value gezet. Dit zodat als ze een foutieve invoer hebben gedaan en ze worden terug gestuurd, deze niet
   volledig opnieuw opgezet hoeft te worden. Wel zo klant vriendelijke lijkt me.
   
   **/
 
 
   // hier moet een eventuele foutmelding komen.
   if(is_array($foutje)){
      $foutweergave = "<span style=\"color:red;font-weight:bold;\">We hebben de volgende fouten geconstateerd:<ul>";
      foreach($foutje as $fout){
         $foutweergave .= "<li>".$fout."</li>\n";
      }
      $foutweergave .= "</ul></span>";
   }
 
 
 
$text = <<<TEMPLATE
<form method="post" action="add2.php" onsubmit="return checkSubmit(this);"><input type="hidden" name="action" value="doadd">
[+][-]06.13.2008 at 12:30AM PDT, ID: 21776626

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.13.2008 at 03:04AM PDT, ID: 21777317

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.13.2008 at 03:07AM PDT, ID: 21777328

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 12:21AM PDT, ID: 21961224

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, PHP and Databases
Sign Up Now!
Solution Provided By: Milcoi
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628