Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Fabyo

Upload de foto e salvando o path no banco

Recommended Posts

Ae gente eu tenho os seguintes códigos...

PAgina de cadastro de filmes

 

 

 

<?php require_once('Connections/Conection.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "Mikael";
$MM_donotCheckaccess = "false";
// *** 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 == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "index.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"] == "cadastro")) {
$insertSQL = sprintf("INSERT INTO filmes (Nome, Genero, Faixa_Etaria, Sinopse, `Data de Lancamento`, Classificador) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nome_filme'], "text"),
GetSQLValueString($_POST['genero'], "text"),
GetSQLValueString($_POST['Faixa'], "text"),
GetSQLValueString($_POST['sinopse'], "text"),
GetSQLValueString($_POST['data_lancamento'], "date"),
GetSQLValueString($_POST['classificador'], "text"));
mysql_select_db($database_Conection, $Conection);
$Result1 = mysql_query($insertSQL, $Conection) or die(mysql_error());
$insertGoTo = "cadastrar_filmes.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cadastrar Filmes</title>
<link href="Folha de Estilos.css" rel="stylesheet" type="text/css">
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationCheckbox.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
<link href="SpryAssets/SpryValidationCheckbox.css" rel="stylesheet" type="text/css">
</head>
<body class="Fundo_Pagina" >
<table width="670" border="0" align="center">
<tr>
<td><img src="Imagens/Outros/Topo.png" width="668" height="188"></td>
</tr>
</table>
<span class="Fundo_Pagina"></span>
<span class="Fundo_Pagina"></span>
<span class="Fundo_Pagina"></span>
<table width="670" border="0" align="center" class="Fundo_Acesso">
<tr>
<td width="659" align="center"><form action="<?php echo $editFormAction; ?>" method="POST" name="cadastro" class="login">
<p><br>
<span class="texto">Cadastro de Filmes</span></p>
<p><span id="sprytextfield1">
<label for="nome_filme">Nome do Filme</label>:
<input type="text" name="nome_filme" id="nome_filme">
<span class="textfieldRequiredMsg">Um valor é necessário.</span></span></p>
<fieldset>
<legend>Genero</legend>
<p>
<label>
<input type="checkbox" name="genero" value="Ação" id="genero_0">
Ação</label>
<label>
<input type="checkbox" name="genero" value="Aventura" id="genero_1">
Aventura</label>
<label>
<input type="checkbox" name="genero" value="Comédia" id="genero_2">
Comédia</label>
<input type="checkbox" name="genero" value="Drama" id="genero_5">
Drama<br>
<input type="checkbox" name="genero" value="Épico" id="genero_6">
Épico
<input type="checkbox" name="genero" value="Infantil" id="genero_7">
Infantil
<input type="checkbox" name="genero" value="Policial" id="genero_8">
Policial
<label>
<input type="checkbox" name="genero" value="Suspense" id="genero_4">
Suspense</label>
<label>
<input type="checkbox" name="genero" value="Terror" id="genero_3">
Terror</label>
<br>
</p>
</fieldset>
<fieldset>
<legend>Faixa Etária</legend>
<p>
<label>
<input type="radio" name="Faixa" value="Livre" id="Faixa_0">
Livre</label>
<label>
<input type="radio" name="Faixa" value="Acima de 12" id="Faixa_1">
+12</label>
<label>
<input type="radio" name="Faixa" value="Acima de 14" id="Faixa_2">
+14</label>
<label>
<input type="radio" name="Faixa" value="Acima de 16" id="Faixa_3">
+16</label>
<label>
<input type="radio" name="Faixa" value="Acima de 18" id="Faixa_4">
+18 </label>
<br>
</p>
</fieldset>
<p>
<label for="sinopse">Sinopse: </label>
<textarea name="sinopse" id="sinopse" cols="30" rows="5"></textarea>
</p>
<p><span id="sprytextfield4">
<label for="data_lancamento">Data de Lançamento</label>
<input type="text" name="data_lancamento" id="data_lancamento">
<span class="textfieldRequiredMsg">Um valor é necessário</span></span> </p>
<fieldset>
<legend>Classificador</legend>
<p>
Acervo
<input type="radio" name="classificador" id="classificador" value="Acervo">  
<label for="classificador"></label>
 Lançamento
<input type="radio" name="classificador" id="classificador2" value="Lançamento">
</p>
</fieldset>
<p>
<input name="cadastrar" type="submit" class="bt-login" id="cadastrar" value="Cadastrar">
</p>
<p>
<input type="hidden" name="MM_insert" value="cadastro">
</p>
</form>
<form name="form1" method="post" action="">
<p>
<input name="voltar3" type="submit" class="bt-login" id="voltar3" onClick="action="alterar_filmes.php"" value="Alterar"> 
<input name="voltar4" type="submit" class="bt-login" id="voltar4" onClick="action="excluir_filmes.php"" value="Excluir">
<br>
<br>
<input name="voltar" type="submit" class="bt-login" id="voltar" onClick="action="index.php"" value="Voltar A Pagina Inicial">
</p>
<p>
<input name="voltar2" type="submit" class="bt-login" id="voltar2" onClick="action="gerenciar.php"" value="Voltar A Pagina Anterior">
</p>
</form></td>
</tr>
</table>
<span class="Fundo_Pagina"></span> <script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "custom", {pattern:"00/00/0000", useCharacterMasking:true});
</script>
</body>
</html>
Apos executar a confirmação dos dados... é enviado para o banco de dados. e como eu usei o DW ele n cria uma pagina de função...
porém como eu posso fazer para reutilizar esses códigos ou sei lá fazer a mão mesmo mas utilizar essa pagina e criar a pagina de função talves sei lá... e como estou com pouco tempo eu n estou tendo mt cabeça para descubrir como faço para dar certo...
OBS: nessa pagina tinha um campo de Arquivos que eu tirei pq n estava funcionando e precisava do site rodando para apresentação previa para o projeto da faculdade.. agora preciso arrumar alguns detalhes..
agradeço desde já!

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.