Ir para conteúdo

POWERED BY:

Arquivado

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

Lawiet Henrique

[E]rror Undefined offset: 1054

Recommended Posts

Estou Com Um Problema, Quando Eu Vou Acessar o Meu Cadrasto.php Da o Seguinte Error:

 

4msz.png

 

Estou Baixei o Cadrasto.zip Do Fabyo, Estou Tentando Fazer Umas Alterações e Adaptações Para o Swift Panel, Não Sou Nenhum Formado Em Php Sou Apenas Um Aprendiz...

 

Link Do Arquivo Zip [Original]

 

http://forum.imasters.com.br/index.php?app=core&module=attach&section=attach&attach_id=174

 

Link Do Topico Do Fabyo

 

http://forum.imasters.com.br/topic/192408-sistema-de-cadastro-em-phpmysql/

 

-----------------------------------------------------------------------------------------------------------------------------------

 

Download Code:

 

http://www.mediafire.com/?wz9dayii3o9da14

Compartilhar este post


Link para o post
Compartilhar em outros sites

Sim, Aguarde Uns Minutos....

 

Cadrasto.php

 

 

<?php
if(file_exists("init.php")) {
require "init.php";
} else {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
if(!function_exists("Abre_Conexao")) {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
Abre_Conexao();
$re = mysql_query("select * from estados order by estado");
if(mysql_errno() != 0) {
if(!isset($erros)) {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte \$erros";
exit;
}
echo $erros[mysql_errno()];
exit;
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>eGamesHost - Cadrasto</title>
<link href="templates/default/images/favicon.ico" rel="shortcut icon" />
<link href="templates/default/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="topbg"></div>
<div id="nav"></div>
<div id="Cadrasto">
<br />
<p align="center"><h1>Cadrastro</h1></p>
<br />
<form id="form1" name="form1" method="post" action="Cadrasto.php">
<table width="400" border="0" align="left">
<tr>
<td width="145">Nome</td>
<td width="245"><input name="firstname" type="text" id="nome" maxlength="30" /></td>
</tr>
<tr>
<td>Sobrenome</td>
<td><input name="lastname" type="text" id"sobrenome" maxlength="30" /></td>
</tr>
<tr>
<td>Empresa</td>
<td><input name="email" type="text" id="email" maxlength="64" /></td>
</tr>
<tr>
<td>E-mail</td>
<td><input name="usuario" type="text" id="login" maxlength="40" /></td>
</tr>
<tr>
<td>Senha</td>
<td><input name="senha" type="password" id="senha" maxlength="10" /></td>
</tr>
<tr>
<td>Telefone</td>
<td><input name="Telefone" type="tel" id="telefone" maxlength="10" /></td>
</tr>
</table>
<table width="400" border="0" align="right">
<tr>
<td width="145">Endereço</td>
<td width="245"><input name="firstname" type="text" id="nome" maxlength="30" /></td>
</tr>
<tr>
<td>Bairro</td>
<td><input name="lastname" type="text" id"sobrenome" maxlength="30" /></td>
</tr>
<tr>
<td>Cidade</td>
<td><input name="email" type="text" id="email" maxlength="64" /></td>
</tr>
<tr>
<td>Estado</td>
<td><select name="estados" id="estados" class="textBox" >
<?php
while($l = mysql_fetch_array($re)) {
$id = $l["id_estado"];
$estado = $l["estado"];
$uf = $l["uf"];
echo "<option value=\"$id\">$uf - $estado</option>\n";
}
@mysql_close();
?>
</select> </td>
</tr>
<td>CEP</td>
<td><input name="senha" type="password" id="senha" maxlength="10" /></td>
</tr>
<tr>
<td>País</td>
<td><input name="Telefone" type="text" id="pais" maxlength="8" /></td>
</tr>
</table>
</form>
</body>
</html>

 

Config.php

 

 

 

<?php
define("SERVIDOR", "localhost");
define("USUARIO", "root");
define("SENHA", "Senha");
define("BANCO", "cadrasto");
?>

 

Editar.php

 

 

 

<?php
if(file_exists("init.php")) {
require "init.php";
} else {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
if(!function_exists("Abre_Conexao")) {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
$id = $_GET["id"];
Abre_Conexao();
$re = mysql_query("select count(*) as total from client where clientid = $id");
$total = mysql_result($re, 0, "total");
if($total == 1) {
$re = mysql_query("select * from client, estados where estados.id_estado = usuarios.state and usuarios.clientid = $id");
$dados = mysql_fetch_array($re);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cadastro</title>
<style>
<!--
.textBox { border:1px solid gray; width:200px;}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="salvar_edicao.php">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<table width="400" border="0" align="center">
<tr>
<td width="145">Nome</td>
<td width="245"><input name="nome" type="text" id="nome" maxlength="45" class="textBox" value="<?php echo $dados["nome"]; ?>" /></td>
</tr>
<tr>
<td>Email</td>
<td><input name="email" type="text" id="email" maxlength="64" class="textBox" value="<?php echo $dados["email"]; ?>" /></td>
</tr>
<tr>
<td>Data Nascimento</td>
<td>
<?php
$arr = explode("-", $dados["data_nascimento"]);
echo Seleciona_Item($arr[2], monta_select("dia", 1, 31));
echo Seleciona_Item($arr[1], monta_select("mes", 1, 12));
echo Seleciona_Item($arr[0], monta_select("ano", 1940, 1988));
?>
</td>
</tr>
<tr>
<td>Sexo</td>
<td><input name="sexo" type="radio" value="M" <?php echo $dados["sexo"] == "M" ? "checked=\"checked\"" : ""; ?> /><label>Masculino</label>
<input name="sexo" type="radio" value="F" <?php echo $dados["sexo"] == "F" ? "checked=\"checked\"" : ""; ?> /> <label>Feminino</label></td>
</tr>
<tr>
<td>Preferencias de Filmes </td>
<td><select name="preferencias[]" class="textBox" multiple="multiple" id="preferencias">
<?php
$combo = "<option value=\"R\">Romance</option>
<option value=\"S\">Suspense</option>
<option value=\"P\">Policial</option>
<option value=\"F\">Ficção</option>";
$arr = explode(",", $dados["preferencias"]);
for($i = 0; $i < count($arr); $i++) {
$combo = preg_replace("#<option value=\"{$arr[$i]}\">#is", "<option value=\"{$arr[$i]}\" selected=\"selected\">", $combo);
}
echo $combo;
?>
</select>
</td>
</tr>
<tr>
<td>Salario</td>
<td><input name="salario" type="text" id="salario" maxlength="5" class="textBox" /></td>
</tr>
<tr>
<td>Endereco</td>
<td><input name="endereco" type="text" id="endereco" maxlength="30" class="textBox" /></td>
</tr>
<tr>
<td>Bairro</td>
<td><input name="bairro" type="text" id="bairro" maxlength="20" class="textBox" /></td>
</tr>
<tr>
<td>Cidade</td>
<td><input name="cidade" type="text" id="cidade" maxlength="45" class="textBox" /></td>
</tr>
<tr>
<td>Estado</td>
<td><select name="estados" id="estados" class="textBox" >
<option value="0">Selecione</option>
<?php
$re = mysql_query("select * from estados order by estado");
if(mysql_errno() != 0) {
if(!isset($erros)) {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte \$erros";
exit;
}
echo $erros[mysql_errno()];
exit;
}
while($l = mysql_fetch_array($re)) {
$id = $l["id_estado"];
$estado = $l["estado"];
$uf = $l["uf"];
echo Seleciona_Item($dados["id_estado"], "<option value=\"$id\">$uf - $estado</option>");
}
@mysql_close();
?>
</select> </td>
</tr>
<tr>
<td>Login</td>
<td><input name="login" type="text" id="login" maxlength="40" class="textBox" /></td>
</tr>
<tr>
<td>Senha</td>
<td><input name="senha" type="password" id="senha" maxlength="10" class="textBox" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Salvar" style="cursor:pointer;" /></td>
</tr>
</table>
</form>
</body>
</html>

 

Excluir.php

 

 

 

<?php
if($_SERVER["REQUEST_METHOD"] == "GET") {
if(file_exists("init.php")) {
require "init.php";
} else {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
if(!function_exists("Abre_Conexao")) {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
$id = $_GET["id"];
Abre_Conexao();
if(mysql_query("delete from client where clientid = $id")) {
if(mysql_affected_rows() == 1){
echo "Registro deletado com sucesso<br />";
}
}
}
?>
<a href="listar.php">Voltar</a>

 

Funcoes.php

 

 

 

<?php
function monta_select($campo, $start, $end) {
$select = "<select name=\"$campo\" id=\"$campo\">\n";
for($i = $start; $i <= $end; $i++) {
$select .= "\t<option value=\"". sprintf("%02d", $i) ."\">".sprintf("%02d", $i)."</option>\n";
}
$select .= "</select>\n";
return $select;
}
function monta_combo($campo) {
if($campo == "") {
return false;
}
$select = "<select name=\"campo\">\n";
for($i = 0; $i < count($campo); $i++) {
$select .= "\t<option value=\"$i\">{$campo[$i]}</option>\n";
}
$select .= "</select>\n";
return $select;
}
function Pega_Preferencia($campo) {
$campo = explode(",", $campo);
for($i = 0; $i < count($campo); $i++) {
switch ($campo[$i]) {
case "R":
$preferencia[] = "Romantico";
break;
case "S":
$preferencia[] = "Suspense";
break;
case "P":
$preferencia[] = "Policial";
break;
case "F":
$preferencia[] = "Ficção";
break;
}
}
return isset($preferencia) ? $preferencia : false;
}
function Seleciona_Item($valor, $campo) {
return preg_replace("#<option value=\"$valor\">#is", "<option value=\"$valor\" selected=\"selected\">", $campo);
}
?>

 

Init.php

 

 

 

<?php
error_reporting(E_ALL);
@ini_set('display_errors', '1');
@ini_set('register_globals', '0');
if (version_compare(phpversion(), "4", ">")) {
if (!extension_loaded('mysql')) {
echo( "eGamesHost, Error Fatal - Contate Nosso Suporte" );
exit;
}
}
if(file_exists("funcoes.php")) {
include "funcoes.php";
} else {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
if(file_exists("config.php")) {
include "config.php";
if (!defined("SERVIDOR") or !defined("USUARIO") or !defined("SENHA") or !defined("BANCO")){
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
}
$erros[2005] = "Esse servidor nao existe";
$erros[2003] = "Servidor Mysql desligado";
$erros[1045] = "Usuario ou senha invalido";
$erros[1049] = "Banco de dados nao encontrado";
$erros[1146] = "Erro de sql a tabela nao existe";
$erros[1062] = "Erro campo unico na tabela, nao pode cadastrar pois ele ja existe";
function Abre_Conexao() {
global $erros;
@mysql_connect(SERVIDOR, USUARIO, SENHA);
if(mysql_errno() != 0) {
echo $erros[mysql_errno()];
exit;
}
@mysql_select_db(BANCO);
if(mysql_errno() != 0) {
echo $erros[mysql_errno()];
exit;
}
}
?>

 

 

Listar.php

 

 

 

<a href="index.html">Voltar</a>
<?php
if(file_exists("init.php")) {
require "init.php";
} else {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
if(!function_exists("Abre_Conexao")) {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
Abre_Conexao();
$re = mysql_query("SELECT * FROM client INNER JOIN estados ON client.estados = estados.id_estado ORDER BY client.firstname;");
if(mysql_errno() != 0) {
if(!isset($erros)) {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte \$erros";
exit;
}
echo $erros[mysql_errno()];
exit;
}
?>
<table width="100%" border="1">
<tr>
<td>Email</td>
<td>Senha</td>
<td>Nome</td>
<td>Sobrenome</td>
<td>Empresa</td>
<td>Endereco</td>
<td>Bairro</td>
<td>Cidade</td>
<td>Estado</td>
<td>Pais</td>
</tr>
<?php
while($l = mysql_fetch_array($re)) {
$id = $l["clientid"];
$email = $l["email"];
$senha = $l["password"];
$nome = $l["firstname"];
$sobrenome = $l["lastname"];
$empresa = $l["company"];
$endereco = $l["address1"];
$bairro = $l["address2"];
$cidade = $l["city"];
$estado = $l["state"];
$pais = $l["country"];
echo "
<tr>
<td><a href=\"editar.php?id=$id\">[Editar]</a> <a href=\"excluir.php?id=$id\">[Excluir]</a></td>
<td> $email</td>
<td> $senha</td>
<td> $nome</td>
<td> $sobrenome</td>
<td> $empresa</td>
<td> $endereco</td>
<td> $bairro</td>
<td> $cidade</td>
<td> $estado</td>
<td> $pais</td>
</tr>\n";
}
@mysql_close();
?>
</table>

 

Salvar.php

 

 

 

<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
$email = $l["email"];
$senha = $l["password"];
$nome = $l["firstname"];
$sobrenome = $l["lastname"];
$empresa = $l["company"];
$endereco = $l["address1"];
$bairro = $l["address2"];
$cidade = $l["city"];
$estado = $l["state"];
$pais = $l["country"];
if(file_exists("init.php")) {
require "init.php";
} else {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
if(!function_exists("Abre_Conexao")) {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
Abre_Conexao();
if(@mysql_query("INSERT INTO client VALUES ( NULL , '$email', ' MD5( '$senha' )', '$nome' , '$sobrenome',
'$empresa', '$endereco', '$bairro', '$cidade', '$estado', '$pais' )")) {
if(mysql_affected_rows() == 1){
echo "Registro efetuado com sucesso<br />";
}
} else {
if(mysql_errno() == 1062) {
echo $erros[mysql_errno()];
exit;
} else {
echo "Erro nao foi possivel efetuar o cadastro";
exit;
}
@mysql_close();
}
}
?>
<a href="index.html">Voltar</a>

 

Salvar_Edicao.php

 

 

 

<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
$id = $l["clientid"];
$email = $l["email"];
$senha = $l["password"];
$nome = $l["firstname"];
$sobrenome = $l["lastname"];
$empresa = $l["company"];
$endereco = $l["address1"];
$bairro = $l["address2"];
$cidade = $l["city"];
$estado = $l["state"];
$pais = $l["country"];
if(file_exists("init.php")) {
require "init.php";
} else {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
if(!function_exists("Abre_Conexao")) {
echo "eGamesHost, Error Fatal - Contate Nosso Suporte";
exit;
}
Abre_Conexao();
if(@mysql_query("UPDATE client SET email = '$email',
password = MD5( '$senha' ),
firstname = '$nome',
lastname = '$sobrenome',
company = '$empresa',
address1 = '$endereco',
address2 = '$bairro',
city = '$cidade',
state = '$estado',
country = '$pais' WHERE id_usuario = $id")) {
if(mysql_affected_rows() == 1){
echo "Registro atualizado com sucesso";
}
} else {
if(mysql_errno() == 1062) {
echo $erros[mysql_errno()];
exit;
} else {
echo "Erro nao foi possivel efetuar a edição";
exit;
}
@mysql_close();
}
}
?>
<a href="listar.php">Voltar</a>

 

Tabela.sql

 

 

 

DROP TABLE IF EXISTS `client`;
CREATE TABLE IF NOT EXISTS `client` (
`clientid` int(10) unsigned NOT NULL auto_increment,
`email` text NOT NULL,
`password` text NOT NULL,
`firstname` text NOT NULL,
`lastname` text NOT NULL,
`company` text NOT NULL,
`address1` text NOT NULL,
`address2` text NOT NULL,
`city` text NOT NULL,
`state` text NOT NULL,
`postcode` text NOT NULL,
`country` text NOT NULL,
`phone` text NOT NULL,
`notes` text NOT NULL,
`status` text NOT NULL,
`lastlogin` datetime NOT NULL,
`lastip` text NOT NULL,
`lasthost` text NOT NULL,
`created` date NOT NULL,
PRIMARY KEY (`clientid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE estados (
id_estado SMALLINT ( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
uf CHAR ( 2 ) NOT NULL,
state VARCHAR ( 19 ) NOT NULL UNIQUE
);
INSERT INTO estados VALUES ( NULL , "AC", "Acre");
INSERT INTO estados VALUES ( NULL , "AL", "Alagoas");
INSERT INTO estados VALUES ( NULL , "AP", "Amapá");
INSERT INTO estados VALUES ( NULL , "AM", "Amazonas");
INSERT INTO estados VALUES ( NULL , "BA", "Bahia");
INSERT INTO estados VALUES ( NULL , "CE", "Ceará");
INSERT INTO estados VALUES ( NULL , "DF", "Distrito Federal");
INSERT INTO estados VALUES ( NULL , "ES", "Espirito Santo");
INSERT INTO estados VALUES ( NULL , "GO", "Goiás");
INSERT INTO estados VALUES ( NULL , "MA", "Maranhão");
INSERT INTO estados VALUES ( NULL , "MT", "Mato Grosso");
INSERT INTO estados VALUES ( NULL , "MS", "Mato Grosso do Sul");
INSERT INTO estados VALUES ( NULL , "MG", "Minas Gerais");
INSERT INTO estados VALUES ( NULL , "PA", "Pará");
INSERT INTO estados VALUES ( NULL , "PB", "Paraíba");
INSERT INTO estados VALUES ( NULL , "PR", "Paraná");
INSERT INTO estados VALUES ( NULL , "PE", "Pernambuco");
INSERT INTO estados VALUES ( NULL , "PI", "Piauí");
INSERT INTO estados VALUES ( NULL , "RN", "Rio Grande do Norte");
INSERT INTO estados VALUES ( NULL , "RS", "Rio Grande do Sul");
INSERT INTO estados VALUES ( NULL , "RJ", "Rio de Janeiro");
INSERT INTO estados VALUES ( NULL , "RO", "Rondônia");
INSERT INTO estados VALUES ( NULL , "RR", "Roraima");
INSERT INTO estados VALUES ( NULL , "SC", "Santa Catarina");
INSERT INTO estados VALUES ( NULL , "SP", "São Paulo");
INSERT INTO estados VALUES ( NULL , "SE", "Sergipe");
INSERT INTO estados VALUES ( NULL , "TO", "Tocantins");

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.