Problem mit E-Mail-Versand

Rambo51

Erfahrenes Mitglied
Hallo,

ich habe ein Problem, mal wieder^^.

Und zwar wollte ich per Formular eine Email versenden. Und vorher wollte ich noch testen, ob alle Pflichtfelder ausgefüllt worden sind.

Formular.php:
HTML:
<form method="post" action="send.php">
<table width="100%" bgcolor="#615B30" cellspacing="1">
 <tr bgcolor="#B0A755">
  <td width="160" height="25">Clan:<font color="#FF0000">*</font></td>
  <td width="387"><input class="input" type="text" size="35" name="Clan"></td>
 </tr>
 <tr bgcolor="#B7AE64">
  <td height="25">Clantag:<font color="#FF0000">*</font></td>
  <td><input class="input" type="text" size="15" name="Clantag"></td>
 </tr>
 <tr bgcolor="#B0A755">
  <td height="25">Contact ICQ:</td>
  <td><input class="input" type="text" name="Contact ICQ" size="15" value="xxx-xxx-xxx"></td>
 </tr>
 <tr bgcolor="#B7AE64">
  <td height="25">Contact e-Mail:<font color="#FF0000">*</font></td>
  <td><input class="input" type="text" size="35" name="Contact e-Mail"></td>
 </tr>
 <tr bgcolor="#B0A755">
  <td height="25">X vs. X:<font color="#FF0000">*</font></td>
  <td><select class="input" name="X vs X">
	  <option selected>2 vs. 2</option>
	  <option>3 vs. 3</option>
	  <option>4 vs. 4</option>
	  <option>5 vs. 5</option>
	  <option>6 vs. 6</option>
	  </select>
  </td>
 </tr>
 <tr bgcolor="#B7AE64">
  <td height="25">Your Clan Homepage:</td>
  <td><input class="input" type="text" size="45" name="Your Clan Homepage"></td>
 </tr>
 <tr bgcolor="#B0A755">
  <td height="25">Tracker:</td>
  <td><input class="input" type="text" size="45" name="Tracker"></td>
 </tr>
 <tr bgcolor="#B7AE64">
  <td height="25">Server:<font color="#FF0000">*</font></td>
  <td><select class="input" name="Server">
      <option selected>Yes</option>
	  <option>No</option>
	  </select>
  </td>
 </tr>
 <tr bgcolor="#B0A755">
  <td height="25">Other...:</td>
  <td><textarea class="textarea" name="Other" cols="45" rows="5"></textarea><br></td>
 </tr>
 <tr bgcolor="#B7AE64">
  <td height="25" colspan="2" valign="top"><center><input class="input" type="submit" name="submit" value="Fight US"><input class="input" type="reset" name="reset" value="Reset"></center></td>
 </tr>
 <tr bgcolor="#B0A755">
  <td height="25" colspan="2">Necessary fields are marked with an <font color="#FF0000">*</font></td>
 </tr>
</table>
</form>


Send.php:
PHP:
<?php
if ($_REQUEST['submit']) 
 {
  if (($_REQUEST['Clan'] == '') ||
      ($_REQUEST['Clantag'] == '') ||
	  ($_REQUEST['Contact e-Mail'] == '') || 
	  ($_REQUEST['X vs X'] == '') || 
	  ($_REQUEST['Server'] == ''))
     {
       echo "Go <a href=\"javascript:history.back();\">back</a>!";
     }
     else
     {
       mail("mcrambo10@aol.com", "Report", "Blablub", "From: TestMailer");
       echo "Thanks for Mail!";
     } 
 }
else
{
   echo "Error: Go<a href=\"javascript:history.back();\">Back</a>.";
}
?>

Egal ob ich Die Pflichfelder offen lasse oder ausfülle, er schickt keine Email ab. Es kommt immer Go back!

Danke für die hilfe.

Gruss Rambo51
 
Hab mir jetzt nur den if angeschaut.

PHP:
if ($_REQUEST['submit']) 
 {
  if (($_REQUEST['Clan'] == '') ||
      ($_REQUEST['Clantag'] == '') ||
      ($_REQUEST['Contact e-Mail'] == '') || 
      ($_REQUEST['X vs X'] == '') || 
      ($_REQUEST['Server'] == ''))

Diesen Teil solltest du umschreiben ...
1. Statt $_REQUEST $_POST verwenden (ist ja ein postformular)
2. anstatt == '' mit empty (http://php.net/empty) überprüfen, ob die Felder leer sind.

Weiß nicht, ob es dann klappt, könnte aber sein ;)
Wenn nicht werde ich mir das nochmal genauer anschaun.
 
Probier mal Folgendes:
PHP:
<?php

	$_notes = array(
		'error'    => array(),
		'notice'  => array(),
		'success' => array()
	);

	if( isset($_POST['submit']) ) {
		if( !isset($_POST['Clan']) || trim($_POST['Clan']) == '' ) {
			$_notes['error'][] = 'Bitte geben Sie xxx an.';
		}
		...
		if( !isset($_POST['Clantag']) || trim($_POST['Clantag']) == '' ) {
			$_notes['error'][] = 'Bitte geben Sie xxx an.';
		}
	}

	if( isset($_POST['submit']) && empty($_notes['error']) ) {
		echo '<div class="note error"><ul>';
		foreach( $_notes['error'] as $message ) {
			echo '<li>'.$message.'</li>';
		}
		echo '</ul></div>';
		echo '<p>Bitte gehen Sie <a href="javascript:history.back();">zurück zum Formular</a> und füllen die benötigten Felder aus.</p>';
	} else {
		mail('mcrambo10@aol.com', 'Report', 'Blablub', 'From: TestMailer');
		echo '<p>Danke für Ihre Nachricht.</p>';
	}

?>
 
Danke Gumbo.

Aber ich hatte es eigentluich schon gelöst. Ich hatte Irgendjemand_1 zitiert, aber irgendwie ist meine nachricht verschwunden, habe ich auch jetzt erst gesehen.

EDIT: So habe ich es gelöst.

PHP:
if ($_POST['submit']) 
 {
  if (empty($_POST['Clan']) ||
      empty($_POST['Clantag']) ||
	  empty($_POST['Email']) || 
	  empty($_POST['Player']) || 
	  empty($_POST['Server']))
 

Neue Beiträge

Zurück