Autor Beitrag
JungerIslaender
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 427
Erhaltene Danke: 5

Win XP
Delphi 7; Delphi 2005
BeitragVerfasst: Sa 20.06.09 16:17 
Ich hab jetzt eine Seite Home.php,
wenn ich sie öffne verschickt sie eine Email an mich.
1. Wie mache ich es jetzt dass die email erst verschickt wird wenn auf den button absenden gedrückt wird.
2. Wie mache ich es das in der email die namen der ausgewählten Checkboxen drin stehen.
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Sa 20.06.09 16:38 
user profile iconJungerIslaender hat folgendes geschrieben Zum zitierten Posting springen:
Ich hab jetzt eine Seite Home.php,
wenn ich sie öffne verschickt sie eine Email an mich.
1. Wie mache ich es jetzt dass die email erst verschickt wird wenn auf den button absenden gedrückt wird.
2. Wie mache ich es das in der email die namen der ausgewählten Checkboxen drin stehen.


Wie sieht denn dein bisheriger Code aus?

ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
<?php
  if isset($_POST['mysubmit']) {
    //mail senden
  }
?>


<form method="post" action="home.php">
  <input type="submit" name="mysubmit">
</form>
JungerIslaender Threadstarter
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 427
Erhaltene Danke: 5

Win XP
Delphi 7; Delphi 2005
BeitragVerfasst: Sa 20.06.09 16:43 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
while($row=mysql_fetch_array($mysql))
{ //While Schleife zum Auslssen erzeugt Array
echo '<input type="checkbox" name="'.$row["NAME"].'"  <b>'.$row["NAME"].'</b> '. $row["PREIS"].'<br>' ; // Ausgabe: Zeile: Name in tabelle 
}
echo '<br><input type="button" name="senden" value="Senden">';
echo '</body> </html>';

mail($empfaenger, $betreff, $text,"From: $Sender");

if (isset($_POST["senden"])){}


Aber genau
ausblenden Quelltext
1:
if (isset($_POST["senden"])){}					
dass hab ich nicht verstanden wie das funktioniert. Denn jetzt wird sobald man die seite öffnet eine email verschickt.
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Sa 20.06.09 16:46 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
if(isset($_POST["senden"])){
    mail($_POST['empfaenger'], $_POST['betreff'], $_POST['text'],"From: $_POST['sender']");
   }

echo '<form method="POST" action="home.php">';
while($row=mysql_fetch_array($mysql))
{ //While Schleife zum Auslssen erzeugt Array
echo '<input type="checkbox" name="'.$row["NAME"].'"  <b>'.$row["NAME"].'</b> '. $row["PREIS"].'<br>' ; // Ausgabe: Zeile: Name in tabelle 
}
echo '<br><input type="button" name="senden" value="Senden">';
echo '</form></body> </html>';


Bei deinem Code wird alles direkt beim Laden ausgeführt und die then-Klammern der Abfrage hast du leer gelassen. Bei meinem Code wird die Mail erst gesendet wenn $_POST['senden'] einen Wert hat, also erst wenn man auf den submit-Button klickt. Außerdemn hast du das Formular vergessen.
JungerIslaender Threadstarter
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 427
Erhaltene Danke: 5

Win XP
Delphi 7; Delphi 2005
BeitragVerfasst: Sa 20.06.09 17:00 
Wenn ich das einfüge, also meins dadurch ersetze kommt:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in [...] on line 18

Line 18: mail($_POST['empfaenger'], $_POST['betreff'], $_POST['text'],"From: $_POST['sender']");

Edit: AUßerdem wird dann ja immer noch nicht der name der ausgewählten checkbox/en mitgeschickt.


Zuletzt bearbeitet von JungerIslaender am Sa 20.06.09 17:02, insgesamt 1-mal bearbeitet
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Sa 20.06.09 17:02 
Probiers mal so:
ausblenden Quelltext
1:
mail($_POST['empfaenger'], $_POST['betreff'], $_POST['text'],"From: ".$_POST['sender']);					

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
JungerIslaender Threadstarter
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 427
Erhaltene Danke: 5

Win XP
Delphi 7; Delphi 2005
BeitragVerfasst: Sa 20.06.09 17:10 
So es gibt keinen Fehler mehr. Aber es wird nun auch keine E-Mail mehr verschickt^^:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
if(isset($_POST["senden"]))
{
   mail($_POST['empfaenger'], $_POST['betreff'], $_POST['text'],"From: ".$_POST['sender']);
   }

while($row=mysql_fetch_array($mysql))
{ //While Schleife zum Auslssen erzeugt Array
echo '<form method="POST" action="home.php">';
echo '<input type="checkbox" name="'.$row["NAME"].'"  <b>'.$row["NAME"].'</b> '. $row["PREIS"].'<br>' ; // Ausgabe: Zeile: Name in tabelle 
}
echo '<br><input type="button" name="senden" value="Senden">';
echo '</form></body> </html>';
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Sa 20.06.09 17:15 
Du kannst dir mal die einzelnen Parameter mit echo ausgeben lassen, evtl ist da was falsch

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
JungerIslaender Threadstarter
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 427
Erhaltene Danke: 5

Win XP
Delphi 7; Delphi 2005
BeitragVerfasst: Sa 20.06.09 17:17 
welche parameter meinst du?
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Sa 20.06.09 17:28 
die Parameter die du an mail übergibst.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
JungerIslaender Threadstarter
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 427
Erhaltene Danke: 5

Win XP
Delphi 7; Delphi 2005
BeitragVerfasst: Sa 20.06.09 17:37 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
//echo $empfaenger;
//echo $betreff;
//echo $text;
//echo $sender;
echo $_POST['empfaenger'];
echo $_POST['betreff'];
echo $_POST['text'];
echo $_POST['sender'];


Habe ich jetzt geprüft. Die 1. 4 zeigen mir meinen empfaenger und so an. die letzten 4 allerdings nichts.
jfheins
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 918
Erhaltene Danke: 158

Win 10
VS 2013, VS2015
BeitragVerfasst: Sa 20.06.09 19:49 
Du hast anscheinend register_globals aktiviert - das ist unsicher, aber sollte keinen Fehler verursachen.

Versuch mal print_r($_POST); und schreib was rauskommt ;)
JungerIslaender Threadstarter
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 427
Erhaltene Danke: 5

Win XP
Delphi 7; Delphi 2005
BeitragVerfasst: Sa 20.06.09 20:15 
Dann kommt der Fehler Parse error: syntax error, unexpected T_ECHO in [...] on line 25
Hab es jetzt allerdings hinbekommen habe
ausblenden Quelltext
1:
mail($_POST['empfaenger'], $_POST['betreff'], $_POST['text'],"From: ".$_POST['sender']);					


durch

ausblenden Quelltext
1:
mail($empfaenger, $betreff, $text,"From: $Sender");					


ersetzt

Allerdins will ich immernoch die namen meiner angeklickten checkboxen per email verschicken.
JungerIslaender Threadstarter
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 427
Erhaltene Danke: 5

Win XP
Delphi 7; Delphi 2005
BeitragVerfasst: Sa 20.06.09 21:50 
Wunderbar alle hinbekommen!