Jump to content

jopereira

Members
  • Posts

    18
  • Joined

  • Last visited

jopereira's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. it's a school project with already some weeks of work, and before starting I made a presentation along with the plan, but I'm not a guy to always get stick to the plan.. there's some ideias i get while writing code and some i can improve.. in this case, ofc i had it planed, but I wasen't, and I'm not sure what is the best way to implement it with the code i have, and that's what we descussing here so, for your post, I understand I should check the acess always the user acess to another page?
  2. i understand, but that would only work if the webpage already shown all possible links.. in my case, it automatecly prevents a normal user to see admin links in a lytheral way, acesscheck.php works: if user acess = admin echo admin menu echo welcome if user acess = member echo welcome else echo include login.php but mb as soon has the login is made it should check after the session_start what's he's acess level?
  3. hm.. by my understanding i'm getting the acess id ($acess) when the user validates successfully the session (introduces login and password, than press login) after log in is made successfully, that <meta tag> send the $acess, to checkAcess.php and then there is another <meta> - the user is redirected to index page (home) how can he possibily edit his acess level? so as soon as he's redirected, he's acess level is known, and according to it, he will or will not have acess to certain links am I wrong?
  4. i just need to know if my theory how to this is correct
  5. I know what causes the error, I just need some hints to do this welldone, before I care about the erros.. even if I correct them as they are, it wouldnt do what I wanted.. before fighting the errors I need to know if this is going to work as I want when I solve them, I've got this acessChack.php to compare what level of acess the user is, 1 = member, 2 = admin, else = none, and those numbers are sent to $acess by parameter on the validate login script (the first piece of code in my first post in this topic) my guess is that echo "<meta URL=acessCheck.php?acesso=$acess\">"; is not working, but I need your experience and opinion. I need to know if I'm thinking well, else even if i solve the problems i'de have to do it all over again
  6. i'm trying to creat 2 kind of acess from registered users the administrators and the normal members what I thought that I could use is the folowing: <?php // Recebemos os dados digitados pelo utilizador $util = $_POST['utilizador']; $pass = $_POST['password']; $acess = $_POST['acesso']; $conn = mysql_connect("localhost", "root", "") or die("Impossivel conectar"); if($conn) { mysql_select_db("eventos", $conn); } $sql = "SELECT * FROM utilizador WHERE login = '$util' AND senha = '$pass' and acesso = $acess"; $rs = mysql_query($sql, $conn); $num = mysql_num_rows($rs); if($num > 0) { $rst = mysql_fetch_array($rs); $id = $rst["id"]; //$nome = $rst["nome"]; $login = $rst["login"]; $acess = $rst["acesso"]; //Inicia a sessão session_start(); $_SESSION["utilizador"] = $login; mysql_close($conn); echo "<meta http-equiv='refresh' content='0;URL=index.php'>"; } else { mysql_close($conn); echo "<table width='100%' border='1' cellpadding='3' cellspacing='1' bgcolor='#FFFFFF'>"; echo "</table>"; echo "<b>Nenhum utilizador foi encontrado com os dados introduzidos... Por favor, tente novamente. Obrigado</b>"; echo "<meta URL=acessCheck.php?acesso=$acess\">"; echo "<meta http-equiv='refresh' content='4;URL=index.php?>"; } ?> in this piece of code, along with the username and password saving, I also have the $acess varaible which keeps "1" or "2", and in the end it sends the value in the <meta> tag to "acessCheck.php" 1=members acess, 2=administrator acess acessCheck.php: <?php $conn = mysql_connect("localhost", "root", "") or die("Impossivel conectar"); $id = $_SESSION['id']; // session member id $acess = intval($_GET['acesso']); $sql = mysql_query("SELECT * FROM utilizador WHERE acesso='$acess'"); $sqlM = mysql_fetch_assoc($sql); $membro = $sqlM['acesso']; // Isto pega o nivel do membro if($membro == 2) { echo "<p align=left>Bem-vindo(a) ". $_SESSION['utilizador']."</p>"; //mostra informação da sessão echo "<p align=right><a href=admin.php>Administrar</a></p>"; echo "<p align=right><a href=logout.php>Log Out</a></p>"; } else if ($membro == 1) { echo "<p align=left>Bem-vindo(a) ". $_SESSION['utilizador']."</p>"; //mostra informação da sessão echo "<p align=right><a href=logout.php>Log Out</a></p>"; } else { include("login.php"); } ?> and I include acessCheck.php into "index.php" in this piece of code below ... <?php if (isset($_SESSION['utilizador'])) { //echo "<li><a href='#'>Admin</a></li>"; include ("acessCheck.php"); } echo "<br>"; echo "<br>"; ?> ... althought this is returning me this error: Notice: Undefined index: id in C:\xampp\htdocs\xampp\eventos\acessCheck.php on line 4 Notice: Undefined index: acesso in C:\xampp\htdocs\xampp\eventos\acessCheck.php on line 5 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\xampp\eventos\acessCheck.php on line 7 for what I know, if it is returning boolen, which in this case it is status "false".. i understand the select didn't select anything according to the conditions.. I've already checked if the parameter $acess sent was the same everywhere and it is.. my guess is that that <meta> is not doing so good what do you think?
  7. do'h damn I missed the logical thing.. I thought I had already changed that id, but I actually didn't //.- I realy appreciate the way all you people help here, it's such a shame that some teachers dont do that way, resulting in my unknowledge and "personal hate" for php, when it is so easy when you get thing done sorry for beeing dumb :/ my issue is solved here thanks!
  8. nope.. I already saw that and corrected id_eventos is the value that distincts the line of my table (the primary key) and the variable that holds its value is $ref look (pay attention to the <-----------------------------): <?PHP //echo "<link href='default.css' rel='stylesheet' type='text/css' media='all' />"; $conn = mysql_connect("localhost", "root", "") or die("Impossivel conectar"); if($conn) { mysql_select_db("eventos", $conn); } $sql = "SELECT id_eventos, nome FROM eventos"; $rs = mysql_query($sql, $conn); $num = mysql_num_rows($rs); if($num > 0) { //echo "<table border=0 cellpadding=0 cellspacing=0>\n"; while($dados = mysql_fetch_array($rs)) { $ref = $dados["id_eventos"]; <---------------------------------- $nome = $dados["nome"]; /* $img = $dados["imagens"]; echo" <tr>"; echo" <td>$ref</td>"; echo" <td>$desc</td>"; echo" <td>$pvp</td>"; echo" <td>$func</td>"; echo" <td>$garant</td>";*/ // echo "<td>"; //echo "<li><a href=\"mostra_evento.php?id=$ref\"></li>"; echo"<li><a href=\"listar_imagem.php?id_eventos=$ref\">$nome</a></li>";<-------------------------- //echo"</td>"; //echo" </tr>\n"; } } // echo "</table>\n"; ?> <?PHP $conn = mysql_connect("localhost", "root", "") or die("Impossivel conectar"); if($conn) { mysql_select_db("eventos", $conn); } $ref = intval($_GET['id_eventos']);<---------------------------------- $sql = "SELECT * from eventos where id_eventos=$ref"; <---------------------------------- $rs = mysql_query($sql, $conn); $num = mysql_num_rows($rs); if($num > 0) { echo "<table border=0 cellpadding=0 cellspacing=0>\n"; echo "<table border=0 cellpadding=3 cellspacing=0> <tr> <td>Nº de Evento</td> <td>Nome</td> <td>Descrição</td> <td>Requisitos</td> <td>Data</td> <td>Vencedor</td> </tr>"; while($dados = mysql_fetch_array($rs)) { $ref = $dados["id_eventos"]; $nome = $dados["nome"]; $desc = $dados["descricao"]; $req = $dados["requisitos"]; $data = $dados["data"]; $vence = $dados["vencedor"]; //$img = $dados["imagens"]; echo" <tr>"; echo" <td>$id_eventos</td>"; echo" <td>$nome</td>"; echo" <td>$descricao</td>"; echo" <td>$requisitos</td>"; echo" <td>$data</td>"; echo" <td>$vencedor</td>"; echo "<td>"; echo"</td>"; echo" </tr>\n"; } } echo "</table>\n"; ?>
  9. it is a INT value, auto incremet, and I did as you said, but it keeps saying: Notice: Undefined index: ref in C:\xampp\htdocs\xampp\eventos\listar_imagem.php on line 8
  10. i read into some info about $_GET but I found nothing i could use my next guess it's in the script responsible to list the items I got this echo"<li><a href=\"list_event.php?id=$ref\">$name</a></li>"; and on the script responsible to load its info is: $sql = "SELECT * from eventos where id_event=$ref"; ... echo"<a href=\"list_event.php?id=$ref\"></a>"; i think this $ref parameter could help, but how it is now it gives the error: Notice: Undefined variable: ref in C:\xampp\htdocs\xampp\eventos\list_event.php on line 8 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\xampp\eventos\list_event.php on line 10
  11. i'm complity a newbie.. i barely can do a log in system, mutch less debugg. i read what she said, and I understand a good hint to discover the error is to echo where they happear, but.. reading is different than doing :/ btw can you give me more detail info about that $get?
  12. i know.. i just put it there cuz i dont know what to put i think it's some parameter that passes the id, which relates it to the row of the table i want
  13. I've got 3 listed items, like this: Item one Item two Item three each one of this items have a link, but all the 3 items are different rows from the same table, but all the links open the same how can I distinct each one of the links? I got this code: <?PHP //echo "<link href='default.css' rel='stylesheet' type='text/css' media='all' />"; $conn = mysql_connect("localhost", "root", "") or die("Impossivel conectar"); if($conn) { mysql_select_db("eventos", $conn); } $sql = "SELECT id_eventos, nome FROM eventos"; $rs = mysql_query($sql, $conn); $num = mysql_num_rows($rs); if($num > 0) { //echo "<table border=0 cellpadding=0 cellspacing=0>\n"; while($dados = mysql_fetch_array($rs)) { $ref = $dados["id_eventos"]; $nome = $dados["nome"]; /* $img = $dados["imagens"]; echo" <tr>"; echo" <td>$ref</td>"; echo" <td>$desc</td>"; echo" <td>$pvp</td>"; echo" <td>$func</td>"; echo" <td>$garant</td>";*/ // echo "<td>"; //echo "<li><a href=\"mostra_evento.php?id=$ref\"></li>"; echo"<li><a href=\"listar_imagem.php?id=$ref\">$nome</a></li>"; //echo"</td>"; //echo" </tr>\n"; } } // echo "</table>\n"; ?> <?PHP $conn = mysql_connect("localhost", "root", "") or die("Impossivel conectar"); if($conn) { mysql_select_db("eventos", $conn); } $sql = "SELECT * from eventos where id_eventos=1; $rs = mysql_query($sql, $conn); $num = mysql_num_rows($rs); if($num > 0) { echo "<table border=0 cellpadding=0 cellspacing=0>\n"; echo "<table border=0 cellpadding=3 cellspacing=0> <tr> <td>Nº de Evento</td> <td>Nome</td> <td>Descrição</td> <td>Requisitos</td> <td>Data</td> <td>Vencedor</td> </tr>"; while($dados = mysql_fetch_array($rs)) { $ref = $dados["id_eventos"]; $nome = $dados["nome"]; $desc = $dados["descricao"]; $req = $dados["requisitos"]; $data = $dados["data"]; $vence = $dados["vencedor"]; //$img = $dados["imagens"]; echo" <tr>"; echo" <td>$ref</td>"; echo" <td>$nome</td>"; echo" <td>$desc</td>"; echo" <td>$req</td>"; echo" <td>$data</td>"; echo" <td>$vence</td>"; echo "<td>"; echo"<a href=\"listar_imagem.php?id=$id\"></a>"; echo"</td>"; echo" </tr>\n"; } } echo "</table>"; echo "</table>\n"; ?> can you help?
  14. sorry.. i forgot this was an inglish site.. my question is about the links of the listed "items" I've got 3 listed items, like this: Item one Item two Item three each one of this items have a link, but all the 3 items are different rows from the same table, but all the links open the same how can I distinct each one of the links? I got the code above, that is included in the index page, as you can see here: ... <div id="column2"> <h2>Artigos</h2> <ul class="list-style2"> <?php include "listar_evento.php" ?> </ul> <p><a href="#" class="link-style">Read More</a></p> </div> <div id="column3"> <h2>Em Destaque</h2> <p><img src="images/evento1.jpg" width="430" height="200" alt="" /></p> <p>Detalhes do evento publicados em breve.</p> <p><a href="#" class="link-style">Read More</a></p> </div> </div> </div> </div> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.