Hallo zusammen,
so langsam bin ich am verzweifeln :-( Ich habe ein Registrierungsformular mit php erstellt. Der User soll sich hier registrieren können (was auch klappt --> Eintrag in die Datenbank) und gleichzeitig soll eine an den Admin rausgehen, das sich wer registriert hat. Soweit so gut. Eintrag in die Datenbank klappt, Mail geht auch raus. Nur das Problem ist, das in der Mail nix drinsteht. :-( Ich würde mir die Mail gerne so gestalten, das ich nur gewisse Felder per Mail bekomme. Aber wie ich das auch drehe und wende, ich bekomme noch graue Haare. Könnt ihr mir vielleicht helfen?
Hier der PHP-Code für den Eintrag in die Datenbank:
<?php require_once('Connections/SQL.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; }
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } }
$editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); }
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "regist")) { $insertSQL = sprintf("INSERT INTO users (id, autologin, ip, sessionid, username, password, email, country, age, hp, 1, 2, 3, 4, 5, 6) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['id'], "int"), GetSQLValueString($_POST['autologin'], "text"), GetSQLValueString($_POST['ip'], "text"), GetSQLValueString($_POST['sessionid'], "text"), GetSQLValueString($_POST['username'], "text"), GetSQLValueString(md5($_POST['password']), "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['country'], "text"), GetSQLValueString($_POST['age'], "int"), GetSQLValueString($_POST['hp'], "text"), GetSQLValueString($_POST['1'], "text"), GetSQLValueString($_POST['2'], "text"), GetSQLValueString($_POST['3'], "text"), GetSQLValueString($_POST['4'], "text"), GetSQLValueString($_POST['5'], "text"), GetSQLValueString($_POST['6], "text")); mysql_select_db($database_SQL, $SQL); $Result1 = mysql_query($insertSQL, $SQL) or die(mysql_error()); } mysql_select_db($database_SQL, $SQL); $query_Recordset1 = "SELECT * FROM users"; $Recordset1 = mysql_query($query_Recordset1, $SQL) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1);
?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); }
$loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['sessionid'] = $_GET['accesscheck']; }
if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=md5($_POST['password']); $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "mailer.php"; $MM_redirectLoginFailed = "reg-eng.html"; $MM_redirecttoReferrer = true; mysql_select_db($database_SQL, $SQL);
$LoginRS__query=sprintf("SELECT nickname, password FROM users WHERE nickname=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $SQL) or die(mysql_error()); $row = mysql_fetch_array($LoginRS); $loginFoundUser = mysql_num_rows($LoginRS); if($loginFoundUser>0){ $_SESSION['nickname']= $row['nickname'];
if (isset($_SESSION['sessionid']) && true) { $MM_redirectLoginSuccess = $_SESSION['sessionid']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); }
$loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; }
if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=md5($_POST['password']); $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "mailer.php"; $MM_redirectLoginFailed = "reg-ger.html"; $MM_redirecttoReferrer = true; mysql_select_db($database_SQL, $SQL);
$LoginRS__query=sprintf("SELECT nickname, password FROM users WHERE nickname=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $SQL) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && true) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); }
$loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; }
if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=md5($_POST['password']); $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "mailer.php"; $MM_redirectLoginFailed = "reg-eng.html"; $MM_redirecttoReferrer = false; mysql_select_db($database_SQL, $SQL);
$LoginRS__query=sprintf("SELECT nickname, password FROM users WHERE nickname=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $SQL) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); }
$loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; }
if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=md5($_POST['password']); $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "mailer.php"; $MM_redirectLoginFailed = "reg-eng.html"; $MM_redirecttoReferrer = false; mysql_select_db($database_SQL, $SQL);
$LoginRS__query=sprintf("SELECT nickname, password FROM users WHERE nickname=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $SQL) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } if (isset($_POST['nubeagree']) AND $_POST['nubeagree'] != 1) { echo "gesetzt"; } else if (isset($_POST['nubeagree']) != 0) { echo "nicht gesetzt"; } ?> <!doctype html>
Und hier mein Mailer dazu:
<?php // ======= Konfiguration:
$mailTo = 'danny2810@outlook.de'; $mailFrom = '"FormMailer" xxx@outlook.de'; $mailSubject = 'Neue Registration'; $returnPage = 'http://index.html'; $returnErrorPage = 'http://Testfehler.html'; $mailText = "";
// ======= Text der Mail aus den Formularfeldern erstellen:
// Wenn Daten mit method="post" versendet wurden: if(isset($_POST)) { // alle Formularfelder der Reihe nach durchgehen: while(list($strName,$value) = each($_POST)) { // Wenn der Feldwert aus mehreren Werten besteht: // (z.B. <select multiple>) if(is_array($value)) {
$mailText .= $name . ":\n";
foreach($value as $value_array) {
$mailText .= " " . $value . "\n"; } // ENDE: foreach } // ENDE: if
else {
$mailText .= $name . ": " . $value . "\n"; } // ENDE: else } // ENDE: foreach } // if
// ======= Korrekturen vor dem Mailversand
if(get_magic_quotes_gpc()) { // eventuell eingefügte Backslashes entfernen $mailtext = stripslashes($mailtext); }
// ======= Mailversand
$mailSent = @mail($mailTo, $mailSubject, $mailText, "From: ".$mailFrom);
// ======= Return-Seite an den Browser senden
// Wenn der Mailversand erfolgreich war: if($mailSent == TRUE) { // Seite "Formular verarbeitet" senden: header("Location: " . $returnPage); } // Wenn die Mail nicht versendet werden konnte: else { // Seite "Fehler aufgetreten" senden: header("Location: " . $returnErrorPage); }
// ======= Ende
exit();
?>
Vielen Dank schonmal für eure Hilfe