Jump to content


BJ-AMARAL

Member Since 12/07/2004
Offline Last Active 03/08/2008, 11:01
-----

Topics I've Started

Variavel De Resposta

29/05/2007, 21:11

Olá galera,

Estou com mais uma dificuldade no PHP5, estou desenvolvendo um sistema de login.

O erro que esta dando é esse.

Notice: Use of undefined constant erro - assumed 'erro' in C:\www\site_admin\index.php on line 73

Funciona assim a varivel "$erro" so é ativada se o login e senha diverem erradas usando um HEADER( );

mais quando acesso o painel o erro "Notice:" fica ficçado. e num to sabendo como faço para corrigir esse error.

Obrigado pela Atenção

Atenciosamente,
Pedro Amaral

Erro Php 5

29/05/2007, 19:18

Galera funciono, mudei o nome da xml e funciono.


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

Olá galera tudo blz?

Bom tou começando a mecher com PHP5 OOP mais ta dificil, estou fazendo um sistema de login os codigos esta postados, não tenho nem ideia do que pode ser, e outra ele so funciona de vez enquando.

o erro que perciste é esse

"Fatal error: Call to undefined function mysql_connect() in C:\Arquivos de programas\EasyPHP 2.0b1\www\site_admin\db\BancodeDados.class.php on line 17
"
arquivo BancodeDados.class.php
<?php
class BancodeDados {
private $host;
private $username;
private $password;
private $connection;
private $squema;
public function BancodeDados($resource) {
$xml = simplexml_load_file($resource);
$this->host = $xml->sessionfactory->host;
$this->username = $xml->sessionfactory->username;
$this->password = $xml->sessionfactory->password;
$this->squema = $xml->sessionfactory->database;
}
public function conecta() {

$this->connection = mysql_connect($this->host, $this->username,$this->password);
mysql_select_db($this->squema,$this->connection);

return $this->connection;
}

public function desconecta() {
mysql_close($this->connection);
}
public function updateSQL($sql) {
$r = mysql_query($sql,$this->connection);
if($r == 0) {
return false;
} else {
return true;
}
}
public function executaSQL($sql) {
$retorno = mysql_query($sql,$this->connection);
return $retorno;
}
public function iniciarTransacao() {
$this->executaSQL("begin");
}
public function efetivarTransacao() {
$this->executaSQL("commit");
}
public function desfazerTransacao() {
$this->executaSQL("rollback");
}
} 

?>

arquivo index.php

<?php 
include("config_geral.php");
require_once("db/BancodeDados.class.php");

function autentica($tbl, $login, $senha)
	{
 #CHAMA O MÉTODO DE CONEXÃO COM O BANCO DE DADOS.
 $banco = new BancodeDados("db/conn.xml");
 $banco->conecta();
 #VERIFICA SE EXISTE ALGUM LOGIN CADASTRADO NO BANCO COM O INFOMRADO.
 $query = mysql_query("select senha_user, login_user from $tbl WHERE login_user='".sha1($login)."' AND senha_user='".sha1($senha)."'  ") or die("ERRO4: ".mysql_error());  
	 #VERIFICA SE A SENHA INFORMADA É VÁLIDA.
	 if(mysql_num_rows($query)>0):
	 $this->msg = "LOGADO COM SUCESSO";
	 //header("location: ?now=cadastrar&msg=OPERAÇÃO REALIZADA COM SUCESSO"); 
	 else:
	 $this->msg = "SENHA INVÁLIDA";	  
	 endif;

 return $this->msg;
 }

#VERIFICA A ENTRADA DOS CAMPOS.
if(!empty($_POST['login']) && !empty($_POST['senha']) ):
	#FAZ A AUTENTICAÇÃO.
	autentica("usuario",$_POST['login'],$_POST['senha']);
endif;
?>

<!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>. :: <?php echo $titulo_admin; ?> - Login :: .</title>
<style type="text/css">
body {
	background-color: #A5ADB0;
}
</style>
<link href="img_admin/admin.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="705" border="0" align="center" cellpadding="0" cellspacing="0">
	<!-- fwtable fwsrc="tela login admin.png" fwbase="login.jpg" fwstyle="Dreamweaver" fwdocid = "1915283636" fwnested="0" -->
	<tr>
	  <td><img src="img_admin/spacer.gif" width="158" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="10" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="220" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="128" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="24" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="141" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="24" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="1" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td colspan="7"><img name="login_r1_c1" src="img_admin/login_r1_c1.jpg" width="705" height="20" border="0" id="login_r1_c1" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="20" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td rowspan="2" colspan="3"><img name="login_r2_c1" src="img_admin/login_r2_c1.jpg" width="388" height="89" border="0" id="login_r2_c1" alt="" /></td>
	  <td colspan="3"><img name="login_r2_c4" src="img_admin/login_r2_c4.jpg" width="293" height="72" border="0" id="login_r2_c4" alt="" /></td>
	  <td rowspan="6"><img name="login_r2_c7" src="img_admin/login_r2_c7.jpg" width="24" height="385" border="0" id="login_r2_c7" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="72" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td colspan="3"><img name="login_r3_c4" src="img_admin/login_r3_c4.jpg" width="293" height="17" border="0" id="login_r3_c4" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="17" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td rowspan="2" colspan="2"><img name="login_r4_c1" src="img_admin/login_r4_c1.jpg" width="168" height="90" border="0" id="login_r4_c1" alt="" /></td>
	  <td colspan="2" background="img_admin/login_r4_c3.jpg"><img name="login_r4_c3" src="img_admin/user_incorreto.jpg" width="348" height="74" border="0" id="login_r4_c3" alt="" /></td>
	  <td rowspan="2" colspan="2"><img name="login_r4_c5" src="img_admin/login_r4_c5.jpg" width="165" height="90" border="0" id="login_r4_c5" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="74" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td colspan="2"><img name="login_r5_c3" src="img_admin/login_r5_c3.jpg" width="348" height="16" border="0" id="login_r5_c3" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="16" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td rowspan="2"><img src="img_admin/login_r6_c1.jpg" alt="" name="login_r6_c1" width="158" height="206" border="0" usemap="#login_r6_c1MapMap" id="login_r6_c1" /></td>
	  <td colspan="4" background="img_admin/login_r6_c2.jpg"><table width="100%" height="104" border="0" cellpadding="0" cellspacing="0">
		  <tr>
			<td width="12%"> </td>
			<td width="23%"><div align="right" class="style1">Usuário:</div></td>
			<td width="65%"><input name="login" type="text" class="form_login" id="login" size="25" /></td>
		  </tr>
		  <tr>
			<td> </td>
			<td><div align="right" class="style1">Senha:</div></td>
			<td><input name="senha" type="text" class="form_login" id="senha" size="25" /></td>
		  </tr>
		  <tr>
			<td> </td>
			<td> </td>
			<td><input name="imageField" type="image" src="img_admin/entrar.jpg" alt="Logar ao sistema" /></td>
		  </tr>
	  </table></td>
	  <td rowspan="2"><img name="login_r6_c6" src="img_admin/login_r6_c6.jpg" width="141" height="206" border="0" id="login_r6_c6" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="149" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td colspan="4"><img name="login_r7_c2" src="img_admin/login_r7_c2.jpg" width="382" height="57" border="0" id="login_r7_c2" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="57" border="0" alt="" /></td>
	</tr>
  </table>
  <map name="login_r6_c1MapMap" id="login_r6_c1MapMap">
	<area shape="rect" coords="14,138,65,181" href="java script:history.back(-1);" alt="Voltar" />
  </map>
</form>
<map name="login_r6_c1Map" id="login_r6_c1Map">
<area shape="rect" coords="14,138,65,181" href="java script:history.back(-1);" />
</map></body>
</html>

arquivo conn.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<xml>
<sessionfactory>
<host>localhost</host>
<username>root</username>
<password></password>
<database>usuarios_admin</database>
</sessionfactory>
</xml>

Bom galera, espero um ajuda de vocês.

Obrigado pela atenção,

Atenciosamente,
Pedro Amaral

Puxando Arrays Em Ajax

18/10/2006, 19:26

Boa noite pessoal,

Bom estou desenvolvendo um sistema de venda com ajax, o unico problema que eu to encontrando é como puxar arrays tipo assim.

<input type="hidden" name="efetivar" value="1" />
<input type="hidden" name="ttprod[<? echo $indice;?>][DESCRI]"  value="<? echo $descri_produto; ?>" />
<input type="hidden" name="prod[<? echo $indice;?>][DESCONTO]"  value="<? echo $desconto; ?>" />
<input type="hidden" name="rod[<? echo $indice;?>][PRECO]"  value="<? echo $preco; ?>" />
<input type="hidden" name="prod[<? echo $indice;?>][IMAGEM]"  value="<? echo $imagem; ?>" />
<input type="hidden" name="prod[<? echo $indice;?>][PESO]"  value="<? echo $peso; ?>" />
<input type="hidden" name="prod[<? echo $indice;?>][REF]"  value="<? echo $ref; ?>" />
<input type="hidden" name="prod[<? echo $indice;?>][CODIGO]"  value="<? echo $codigo; ?>" />

<? echo urlencode("<input name=\"quant_prod\" type=\"text\" class=\"formulario1\" value=\"0\" size=\"4\" onchange=\"java script:carregaPag('carrinho', 'php', 'busc_produto', '?tipo_busc=4&efetivar=1&idprod=$indice&quant_prod='+quant_prod.value+'')\"/>");?>


ai vem o problema, como faço para pegar arrays com o link em ajax. se eu tento colocar assim por exemplo no input " name="quant_prod[]" " pelo que eu vi o é que ele não aceita arrays,

Valeus pessoal, espero alguns comentarios e ate uma resposta

Muito obrigado pela atenção,

IPB Skin By Virteq