<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO int_mail (an, von, betreff, text, IP) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['an'], "int"),
GetSQLValueString($_POST['von'], "int"),
GetSQLValueString($_POST['betreff'], "text"),
GetSQLValueString($_POST['text'], "text"),
GetSQLValueString($_POST['IP'], "text"));
mysql_select_db($database_db, $db);
$Result1 = mysql_query($insertSQL, $db) or die(mysql_error());
$insertGoTo = "int_mail_gespeichert.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
//Prüfe ob Username vorhanden
$sql = "SELECT `user_name`, `user_id` FROM `user` WHERE `user_name` = "'.$_POST['an'].'"";
$res = mysql_query($sql);
$row = mysql_fetch_assoc($res);
if(isset($row)) {
$qry = "INSERT INTO `int_mail` (`An`) values ('".$row['user_id']."')";
$res = mysql_query($qry);
} else {
olé olé olé
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>neue Nachricht schreiben - <?php echo $_SESSION['MM_Username']?></title>
<link href="../../css/style1.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>neue Nachricht schreiben - <?php echo $_SESSION['MM_Username']?></h1>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">An:</td>
<td><input type="text" name="an" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Betreff:</td>
<td><input type="text" name="betreff" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">Text:</td>
<td><textarea name="text" cols="50" rows="5"></textarea>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Nachricht senden"></td>
</tr>
</table>
<input type="hidden" name="von" value="<?php echo $_SESSION["user_id"]?>">
<input type="hidden" name="IP" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
<input type="hidden" name="MM_insert" value="form1">
</form>