El archivo que tiene el formulario (nuevanoticia2.php):
Aca es es donde quiero que aparezca en el campo "AUTOR" el nombre de usuario y apellido que corresponde al nombre de usuario.
Código PHP:
<?php require_once('Connections/uf.php'); ?>
<?php
session_start();
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"] == "insertar_noticia")) {
$insertSQL = sprintf("INSERT INTO noticias (autor, titulo, resumen, noticia, fecha) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['autor'], "text"),
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['resumen'], "text"),
GetSQLValueString($_POST['noticia'], "text"),
GetSQLValueString($_POST['fecha'], "text"));
mysql_select_db($database_uf, $uf);
$Result1 = mysql_query($insertSQL, $uf) or die(mysql_error());
}
mysql_select_db($database_uf, $uf);
$query_noticias_uf = "SELECT * FROM noticias ORDER BY id ASC";
$noticias_uf = mysql_query($query_noticias_uf, $uf) or die(mysql_error());
$row_noticias_uf = mysql_fetch_assoc($noticias_uf);
$totalRows_noticias_uf = mysql_num_rows($noticias_uf);
$colname_usuarios = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_usuarios = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_uf, $uf);
$query_usuarios = sprintf("SELECT * FROM usuarios WHERE usuario = '%s'", $colname_usuarios);
$usuarios = mysql_query($query_usuarios, $uf) or die(mysql_error());
$row_usuarios = mysql_fetch_assoc($usuarios);
$totalRows_usuarios = mysql_num_rows($usuarios);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
.letra {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
list-style-position: inside;
list-style-image: url((URL));
list-style-type: circle;
}
.campo {
border: 1px solid #CCF0FE;
background-color: #FFFFFF;
}
.boton {
background-color: #D8F3FE;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #FFFFFF;
border-right-color: #FFFFFF;
border-bottom-color: #FFFFFF;
border-left-color: #FFFFFF;
}
.fecha {
color: #666666;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: normal;
}
.Estilo1 {
font-size: 11px;
font-weight: bold;
}
.Estilo4 {
color: #666666;
font-size: 10px;
}
.Estilo9 {color: #666666; font-size: 13px; }
-->
</style>
</head>
<body>
<table width="350" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td width="100%"><span class="Estilo1">Hoy es:</span><span class="fecha">
<?php
$dias = array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
$meses = array("Diciembre","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre");
$numero=Date(" j");
echo $dias[date('w')];
echo Date(" j");
echo " de ";
echo $meses[date('n')];
echo " de ";
echo Date("Y");
?>
</span></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td height="20" align="center" bgcolor="#D8F3FE"><span class="Estilo4">Complete el siguiente formulario para publicar una nueva noticia </span></td>
</tr>
<tr>
<td align="right"> </td>
</tr>
</table>
<table width="350" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="331" valign="top"><form id="insertar_noticia" name="insertar_noticia" method="POST" action="<?php echo $editFormAction; ?>">
<table width="100%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="68" height="30" align="right"><span class="Estilo9">Fecha: </span></td>
<td width="4" height="30" align="right"> </td>
<td width="229" height="30"><span class="letra">
<label></label>
<input name="fecha" type="text" class="campo" id="fecha" value="DD/MM/AAAA" />
</span></td>
</tr>
<tr>
<td width="68" height="30" align="right" valign="middle"><span class="Estilo9">Autor:</span></td>
<td width="4" height="30" align="right" valign="middle"> </td>
<td width="229" height="30" valign="middle"><span class="letra">
<input name="autor" type="text" class="campo" id="autor" />
</span></td>
</tr>
<tr>
<td width="68" height="30" align="right"><span class="Estilo9">Titulo:</span></td>
<td width="4" height="30" align="right"> </td>
<td width="229" height="30"><span class="letra">
<input name="titulo" type="text" class="campo" id="titulo" />
</span></td>
</tr>
<tr>
<td width="68" height="30" align="right" valign="top"><span class="Estilo9"><br />
Resumen: </span></td>
<td width="4" height="30" align="right"> </td>
<td width="229" height="30"><label> <br />
<textarea name="resumen" cols="30" rows="4" class="campo" id="resumen"></textarea>
</label></td>
</tr>
<tr>
<td width="68" height="30" align="right" valign="top"><span class="Estilo9"><br />
Noticia: </span></td>
<td width="4" height="30" align="right"> </td>
<td width="229" height="30"><label> <br />
<textarea name="noticia" cols="30" rows="9" class="campo" id="noticia"></textarea>
</label></td>
</tr>
<tr>
<td height="30" align="right" valign="top"> </td>
<td height="30" align="right"> </td>
<td height="30"><label>
<input name="Submit" type="submit" class="boton" value="Enviar" />
</label></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="insertar_noticia">
</form>
</td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($noticias_uf);
mysql_free_result($usuarios);
?>