Hello. I'm compiling my final questions on this thread - I need some answers today, I'm short on time and I have to finish this project so I can hand it over tomorrow/today (depending on time zone). I really need help, please, you've been great so far, helped a lot, there's just this final bit left now. The questions are numbered below, please give simple answers as i'm a newbie to this: 1. Is it possible to put an image in a table row? If not, i'd like to put it in a table row's background. Here's my code, all it shows is a small image icon: $image=mysql_fetch_assoc(mysql_query("SELECT * FROM imagens WHERE produto=$dados['id_produto']",$connection)); echo "<td><img src='".$image['path']."'></td>"; PHP: 2. http://forums.digitalpoint.com/showthread.php?t=913020 I understand close to nothing JS and I need a clear explanation on this. Here's my actual code with the radio buttons and the text inputs declared: <tr><td align="left"><input type="radio" name="radio_preco" value="aumentar">Raise price</td><td><input type="text" name="preco_aumentar"></td></tr> <tr><td align="left"><input type="radio" name="radio_preco" value="diminuir">Lower price</td><td><input type="text" name="preco_diminuir"> PHP: 3. http://forums.digitalpoint.com/showthread.php?t=911943 I really need some specific code on this one. 4. I basically have a folder for the logged user and a folder for the admin. The scripts contained within the admin's folder can only be acessed by him. So what i want is, at the beginning of the scripts, do this: session_start(); if(!session_is_registered('user')) PHP: But i want to check if user="admin". How to do that? 4Finnally, I need some help with the frame setup, but that i'll ask later when i finish typing all the scripts that will form the project. Please give a hand on this
1. Yes 2. What does that have to do with JS?? 3. Explain more? 4. session_start(); if(!session_is_registered('admin')) Please elaborate more on this.
Thanks a lot on the answer 4, it works. The rest is specified in the links i provided. The questions are inside it. But I'll post all the stuff in this thread if you find it easier to help that way. About question 1, why isn't my code working properly? And how specifically do you put an image onto a table row?
1. - while($image=mysql_fetch_assoc(mysql_query("SELECT * FROM imagens WHERE produto=$dados['id_produto']",$connection))) { #This make it to where it will produce the following code, for every row in imagens where the produto == $dadaos['id_produto'] echo "<td><img src='".$image['path']."'></td>"; } PHP:
Thanks, i'll try it out. Answer 4 doesn't quite work though - I'm now logged as admin, which would mean $user='admin', and it won't let me access admin pages.
I need more info on your login page, your DB, etc. So I know what session variables are set, and more.
I'll post the login script since the $user variable comes from there: <?php session_start(); if(!session_is_registered('user')){ ?> <html> <head> </head> <body> <form action="script_login.php" method="post"> <table> <tr> <td>Nome de utilizador:</td> <td> <input type="text" name="user"></td> </tr> <tr> <td>Palavra Passe:</td> <td> <input type="password" name="pass"></td> </tr> <tr><td><input type="submit" value="Entrar"></td></tr> </table> </form><br/> <b>Ainda</b> não se registou? Não perca a oportunidade de desfrutar dos nossos produtos, <a href="registo.php">registe-se</a>! <?php } else{ header( "Location: http://localhost/PAT/logado.php" ); } ?> </body> </html> PHP: Script_login file: <?php session_start(); if(!session_is_registered('user')){ $user=addslashes($_POST['user']); $pass=md5($_POST['pass']); If (!isset($user) || !isset($pass)) { header( "Location: http://localhost/PAT/login.php" ); } elseif (empty($user) || empty($pass)) { header( "Location: http://localhost/PAT/login.php" ); } else{ $connection=mysql_connect('localhost','root','average18'); if (!$connection){die('A ligação não foi realizada: ' . mysql_error());} $bd = mysql_select_db("PAT",$connection); if(!$bd){die('Não foi possÃvel encontrar a base de dados: ' . mysql_error());} $query="SELECT * FROM clientes WHERE username='$user' AND password='$pass'"; $login=mysql_query($query,$connection); $autentic=mysql_num_rows($login); if($autentic){ if($user!=='admin'){ session_start(); session_register('user'); ?> <script type="text/javascript"> window.location.href="logado.php"; </script> <?php } else{ session_start(); session_register('user'); ?> <script type="text/javascript"> window.location.href="administrador/produtos.php"; </script> <?php } } else{ ?> <script type="text/javascript"> alert("O nome de utilizador não coincide com a palavra-passe. Tente de novo."); history.go(-1); </script> <?php } } } //Se o utilizador já estiver registado, será redireccionado para a página de logado else{ ?> <script type="type/javascript"> window.location.href='logado.php'; </script> <?php } ?> PHP:
try <?php session_start(); if(empty($_SESSION['user'])){ $user=addslashes($_POST['user']); $pass=md5($_POST['pass']); if (!isset($user) || !isset($pass)) { header( "Location: http://localhost/PAT/login.php" ); } elseif (empty($user) || empty($pass)) { header( "Location: http://localhost/PAT/login.php" ); } else{ $connection=mysql_connect('localhost','root','average18'); if (!$connection){die('A ligação não foi realizada: ' . mysql_error());} $bd = mysql_select_db("PAT",$connection); if(!$bd){die('Não foi possÃvel encontrar a base de dados: ' . mysql_error());} $query="SELECT * FROM clientes WHERE username='$user' AND password='$pass'"; $login=mysql_query($query,$connection); $autentic=mysql_num_rows($login); if($autentic){ if($user!='admin'){ session_start(); $_SESSION["admin"] = "admin"; ?> <script type="text/javascript"> window.location.href="logado.php"; </script> <?php } else{ session_start(); $_SESSION["user"] = "user"; ?> <script type="text/javascript"> window.location.href="administrador/produtos.php"; </script> <?php } } else{ ?> <script type="text/javascript"> alert("O nome de utilizador não coincide com a palavra-passe. Tente de novo."); history.go(-1); </script> <?php } } } //Se o utilizador já estiver registado, será redireccionado para a página de logado else{ ?> <script type="type/javascript"> window.location.href='logado.php'; </script> <?php } ?> PHP: