21. marts 2007 - 13:05
Der er
9 kommentarer og 2 løsninger
fjerne 2 felter fra formular
har ingen ide om PHP hvordan fjerner jeg de 2 dropdowns i nedenstående og sætter et "fast" subject på mailen? /////////////////////////////////// // DO NOT MESS WITH THESE TWO LINES $subject_array = array(); $recipient_array = array(); /////////////////////////////////// // <----- BEGIN CONFIG -----> // Edit only what's between the quotation marks in the below lines. // These will be the subjects that your users can choose from // You can have as many as you want. // Each one must be set up like so: // $subject_array[] = "What You Want This Choice To Be"; // Make sure to remove empty ones that you aren't using. Just delete the entire line. $subject_array[] = "Emnet på mailen"; //$subject_array[] = "Andet"; //$subject_array[] = "Subject Choice 3"; //$subject_array[] = "Subject Choice 4"; //$subject_array[] = "Subject Choice 5"; // Edit only what's between the quotation marks in the below lines. // These lines contain the various people that can be contacted via your form. // You can have as many as you want. // Each one must be set up like so: // $recipient_array["UNIQUE Short Name"] = "email@email.com"; // The "UNIQUE Short Name" will be shown in the select box. // This allows the actual email address to be hidden from the user. // Make sure to remove empty ones that you aren't using. Just delete the entire line. $recipient_array["modtager1"] = "minmail@domaene.dk"; //$recipient_array["modtager2"] = "minmail@domaene.dk"; // <----- END CONFIG -----> if ($_POST['send'] == 'true') { $to = $_POST['to']; $name = $_POST['name']; $cpr = $_POST['cpr']; $lb = $_POST['lb']; $adresse = $_POST['adresse']; $postnummer = $_POST['postnummer']; $by = $_POST['by']; $email = $_POST['email']; $the_subject = $_POST['subject']; $message = $_POST['message']; if (($name == '') OR ($email == '') OR ($message == '')) { $SendMail .= "<div class='emailformMessage''>"; $SendMail .= "Et af felterne er ikke udfyldt. <br>"; $SendMail .= "</div>"; } elseif (ereg('([[:alnum:].-]+)(@[[:alnum:].-]+.+)', $email)) { $recipient = $to; $subject = $the_subject; $additional_headers = "Fra: $email"; $body = "Navn: $name \rCpr: $cpr - $lb \rAdresse: $adresse \rPostnummer: $postnummer \rBy: $by \rEmail: $email \rBesked: $message"; $additional_headers = 'From: webmaster@domaene.dk' . "\r\n" . 'Reply-To: webmaster@domaene.dk' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if (mail($recipient, $subject, $body, $additional_headers)) { $SendMail .= "<div class='emailformMessage'>"; $SendMail .= "<h4>Beskeden er sendt!</h4><br><br>"; $SendMail .= "</div>"; $name=""; $cpr=""; $lb=""; $adresse=""; $postnummer=""; $by=""; $email=""; $message=""; } else { $SendMail .= "<div class='emailformMessage'>"; $SendMail .= "Der er opstået en Fejl ! Prøv venligst igen.<br>"; $SendMail .= "</div>"; $send = "false"; } } else { $SendMail .= "<div class='emailformMessage'>"; $SendMail .= "Email adressen der er angivet (".$email.") er ikke en korrekt email adresse. Prøv venligst igen.<br>"; $SendMail .= "</div>"; $send = "false"; } } else { $SendMail .= "<div class='emailformMessage'>"; //$SendMail .= "Vælg hvem som skal modtage denne mail.<br>"; $SendMail .= "</div>"; } $SendMail .= "<div class = 'emailform'>"; $SendMail .= "<form name = 'EmailForm' method = 'post' action=''>"; $SendMail .= "<input type='hidden' name='send' value='true'>"; $SendMail .= "<select name='to'>"; foreach ($recipient_array as $key => $value) { $SendMail .= "<option value= " . $value . ">" . $key . "</option>"; } $SendMail .= "</select><br><br>"; $SendMail .= "Dit navn:<br><input type='text' size='40' name='name' value=".$name."><br>"; $SendMail .= "Cpr-nummer:<br><input type='text' size='11' name='cpr' value=".$cpr."> - <input type='text' size='4' name='lb' value=".$lb."> (Obs! sendes ukrypteret !)<br>"; $SendMail .= "Adresse:<br><input type='text' size='40' name='adresse' value=".$adresse."><br>"; $SendMail .= "Postnummer og By:<br><input type='text' size='4' name='postnummer' value=".$postnummer."> <input type='text' name='by' value=".$by."><br>"; $SendMail .= "Email Adresse:<br>"; $SendMail .= "<input type='text' name='email' size='40' value=".$email."><br><br>"; $SendMail .= "<select name='subject'>"; foreach ($subject_array as $value2) { $SendMail .= "<option value=" . '"'. $value2 .'"' . ">" . $value2 . "</option>"; } $SendMail .= "</select><br>"; $SendMail .= "Besked:<br>"; $SendMail .= "<textarea cols='40' rows='5' name='message'>".$message."</textarea><br><br>"; $SendMail .= "<input type='submit' value='Send'>"; $SendMail .= "<input type='reset' value='Slet'>"; $SendMail .= "</form>"; $SendMail .= "</div>"; return $SendMail;
Annonceindlæg fra Computerworld
21. marts 2007 - 15:43
#1
Du kan fjerne begge dropdown ved at fjerne koden: $SendMail .= "<select name='to'>"; foreach ($recipient_array as $key => $value) { $SendMail .= "<option value= " . $value . ">" . $key . "</option>"; } $SendMail .= "</select><br><br>"; og: $SendMail .= "<select name='subject'>"; foreach ($subject_array as $value2) { $SendMail .= "<option value=" . '"'. $value2 .'"' . ">" . $value2 . "</option>"; } $SendMail .= "</select><br>"; Ligeledes angiver du subject her: $subject = $the_subject; Ret f.eks. til: $subject = "Noget med sjovt";
21. marts 2007 - 16:16
#2
får fejl mail(): SMTP server response: 503 Bad sequence of commands. You must specify the recipients of a message before you can send it
21. marts 2007 - 16:17
#3
Har du lavet en: $to = "minemail@domæne.dk";
21. marts 2007 - 16:24
#4
det har jeg nu - stadig fejl - hvor skal den placeres præcis ?
21. marts 2007 - 19:58
#5
Lige under hvor du satte Subject !
21. marts 2007 - 20:22
#6
får stadig fejl - Nu ser den sådan her ud /////////////////////////////////// // DO NOT MESS WITH THESE TWO LINES $subject_array = array(); $recipient_array = array(); /////////////////////////////////// // <----- BEGIN CONFIG -----> // Edit only what's between the quotation marks in the below lines. // These will be the subjects that your users can choose from // You can have as many as you want. // Each one must be set up like so: // $subject_array[] = "What You Want This Choice To Be"; // Make sure to remove empty ones that you aren't using. Just delete the entire line. $subject_array[] = "Emnet på mailen"; //$subject_array[] = "Andet"; //$subject_array[] = "Subject Choice 3"; //$subject_array[] = "Subject Choice 4"; //$subject_array[] = "Subject Choice 5"; // Edit only what's between the quotation marks in the below lines. // These lines contain the various people that can be contacted via your form. // You can have as many as you want. // Each one must be set up like so: // $recipient_array["UNIQUE Short Name"] = "email@email.com"; // The "UNIQUE Short Name" will be shown in the select box. // This allows the actual email address to be hidden from the user. // Make sure to remove empty ones that you aren't using. Just delete the entire line. $recipient_array["modtager1"] = "minmail@domaene.dk"; //$recipient_array["modtager2"] = "minmail@domaene.dk"; // <----- END CONFIG -----> if ($_POST['send'] == 'true') { $to = $_POST['to']; $name = $_POST['name']; $cpr = $_POST['cpr']; $lb = $_POST['lb']; $adresse = $_POST['adresse']; $postnummer = $_POST['postnummer']; $by = $_POST['by']; $email = $_POST['email']; $the_subject = $_POST['subject']; $message = $_POST['message']; if (($name == '') OR ($email == '') OR ($message == '')) { $SendMail .= "<div class='emailformMessage''>"; $SendMail .= "Et af felterne er ikke udfyldt. <br>"; $SendMail .= "</div>"; } elseif (ereg('([[:alnum:].-]+)(@[[:alnum:].-]+.+)', $email)) { $recipient = $to; $subject = $the_subject; $additional_headers = "Fra: $email"; $body = "Navn: $name \rCpr: $cpr - $lb \rAdresse: $adresse \rPostnummer: $postnummer \rBy: $by \rEmail: $email \rBesked: $message"; $additional_headers = 'From: webmaster@domaene.dk' . "\r\n" . 'Reply-To: webmaster@domaene.dk' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if (mail($recipient, $subject, $body, $additional_headers)) { $SendMail .= "<div class='emailformMessage'>"; $SendMail .= "<h4>Beskeden er sendt!</h4><br><br>"; $SendMail .= "</div>"; $name=""; $cpr=""; $lb=""; $adresse=""; $postnummer=""; $by=""; $email=""; $message=""; } else { $SendMail .= "<div class='emailformMessage'>"; $SendMail .= "Der er opstået en Fejl ! Prøv venligst igen.<br>"; $SendMail .= "</div>"; $send = "false"; } } else { $SendMail .= "<div class='emailformMessage'>"; $SendMail .= "Email adressen der er angivet (".$email.") er ikke en korrekt email adresse. Prøv venligst igen.<br>"; $SendMail .= "</div>"; $send = "false"; } } else { $SendMail .= "<div class='emailformMessage'>"; //$SendMail .= "Vælg hvem som skal modtage denne mail.<br>"; $SendMail .= "</div>"; } $SendMail .= "<div class = 'emailform'>"; $SendMail .= "<form name = 'EmailForm' method = 'post' action=''>"; $SendMail .= "<input type='hidden' name='send' value='true'>"; $SendMail .= "Dit navn:<br><input type='text' size='40' name='name' value=".$name."><br>"; $SendMail .= "Cpr-nummer:<br><input type='text' size='11' name='cpr' value=".$cpr."> - <input type='text' size='4' name='lb' value=".$lb."> (Obs! sendes ukrypteret !)<br>"; $SendMail .= "Adresse:<br><input type='text' size='40' name='adresse' value=".$adresse."><br>"; $SendMail .= "Postnummer og By:<br><input type='text' size='4' name='postnummer' value=".$postnummer."> <input type='text' name='by' value=".$by."><br>"; $SendMail .= "Email Adresse:<br>"; $SendMail .= "<input type='text' name='email' size='40' value=".$email."><br><br>"; $subject = "Noget med sjovt"; $to = "minmail@domæne.dk"; $SendMail .= "Besked:<br>"; $SendMail .= "<textarea cols='40' rows='5' name='message'>".$message."</textarea><br><br>"; $SendMail .= "<input type='submit' value='Send'>"; $SendMail .= "<input type='reset' value='Slet'>"; $SendMail .= "</form>"; $SendMail .= "</div>"; return $SendMail;
21. marts 2007 - 20:30
#7
$subject = "Noget med sjovt"; $to = "minmail@domæne.dk"; Skal flyttes til op over: $recipient = $to; og ændres til: $the_subject = "Noget med sjovt"; $to = "minmail@domæne.dk"; Prøv det
21. marts 2007 - 21:05
#8
super - det virker nu ...tak for det - smider du et svar ?
21. marts 2007 - 22:06
#9
Svar.
21. marts 2007 - 22:12
#10
Ved ikke om du også mener mig. Men her får du et.
22. marts 2007 - 07:51
#11
Takker for point.
Vi tilbyder markedets bedste kurser inden for webudvikling