Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/04/2013, 11:27
camilomascarell1987
 
Fecha de Ingreso: abril-2013
Mensajes: 39
Antigüedad: 13 años, 5 meses
Puntos: 0
Sistema noticia y foto

Bueno tarde, quiero como sistema notica imagenes subir carpeta y php y sql solo foto.png y jpg
codigo
Código PHP:
<?php require_once('Connections/conexion.php'); ?>
<?php
if (!isset($_SESSION)) {
  
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  
// For security, start by assuming the visitor is NOT authorized. 
  
$isValid = False; 

  
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  
if (!empty($UserName)) { 
    
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    
$arrUsers = Explode(",", $strUsers); 
    
$arrGroups = Explode(",", $strGroups); 
    if (
in_array($UserName, $arrUsers)) { 
      
$isValid = true; 
    } 
    
// Or, you may restrict access to only certain users based on their username. 
    
if (in_array($UserGroup, $arrGroups)) { 
      
$isValid = true; 
    } 
    if ((
$strUsers == "") && true) { 
      
$isValid = true; 
    } 
  } 
  return 
$isValid; 
}

$MM_restrictGoTo = "user/login.php";
if (!((isset(
$_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  
$MM_qsChar = "?";
  
$MM_referrer = $_SERVER['PHP_SELF'];
  if (
strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset(
$_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  
header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?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"] == "form1")) {
  
$insertSQL = sprintf("INSERT INTO Noticia (Temas, Foto, text, Video, Nombre, Usuarios) VALUES (%s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['Temas'], "text"),
                       
GetSQLValueString($_POST['Foto'], "text"),
                       
GetSQLValueString($_POST['text'], "text"),
                       
GetSQLValueString($_POST['Video'], "text"),
                       
GetSQLValueString($_POST['Nombre'], "text"),
                       
GetSQLValueString($_POST['Usuarios'], "int"));

  
mysql_select_db($database_conexion, $conexion);
  
$Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
}

$colname_Recordset1 = "-1";
if (isset(
$_SESSION['MM_Username'])) {
  
$colname_Recordset1 = $_SESSION['MM_Username'];
}
mysql_select_db($database_conexion, $conexion);
$query_Recordset1 = sprintf("SELECT `id`, Nombre, Apellido, Usuarios FROM usuario WHERE Usuarios = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $conexion) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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=UTF-8" />
<title>Cocina Sorda</title>
<link href="css/themas.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="contenedor">
  <div id="cabecera"><img src="images/cocina1.png" width="172" height="190" /></div>
  <div class="menu"><a href="index.php">INICIO</a> l <a href="gente.php">GENTE</a> l <a href="user/cuenta.php">CUENTA</a> l <a href="contacto.php">CONTACTO</a></div>
  <?php include("menu.php"); ?>
  <div class="contenidos">
  
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1" enctype="multipart/form-data">
      <table align="center">
        <tr valign="baseline">
          <td height="32">Titulo<br/><input type="text" name="Temas" value="" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td>Foto<br/><input type="file" name="file" id="file"></td>
        </tr>
        <tr valign="baseline">
          <td>Escribe<br/><textarea name="text" cols="60" rows="10">text…..</textarea></td>
        </tr>
        <tr valign="baseline">
          <td>http://youtu.be/<input type="text" name="Video" value="" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td><input type="submit" value="Insertar registro" /></td>
        </tr>
      </table>
      <input name="Nombre" type="hidden" value="<?php echo $row_Recordset1['Nombre']; ?> <?php echo $row_Recordset1['Apellido']; ?>" />
      <input type="hidden" name="Usuarios" value="<?php echo $row_Recordset1['id']; ?>" />
      <input type="hidden" name="Foto" value="<?php echo $_FILES["file"]["name"]; ?>" />
      <input type="hidden" name="MM_insert" value="form1" />
    </form>
  </div>
  <?php include("pie.php"); ?>
</div>
</body>
</html>
<?php
mysql_free_result
($Recordset1);
?>