Foros del Web » Programando para Internet » PHP »

Ayuda con carrito de compra

Estas en el tema de Ayuda con carrito de compra en el foro de PHP en Foros del Web. hola amigos, este es mi primer post y deverdad que necesito su ayuda, encontre en internet un codigo muy bien para crear un carrito de ...
  #1 (permalink)  
Antiguo 04/11/2008, 16:36
 
Fecha de Ingreso: noviembre-2008
Mensajes: 23
Antigüedad: 15 años, 5 meses
Puntos: 0
Ayuda con carrito de compra

hola amigos, este es mi primer post y deverdad que necesito su ayuda, encontre en internet un codigo muy bien para crear un carrito de compras, le he hecho andar a la perfección, mi unico problema es que al tratar de entrar a la seccion de administrador tengo un error que no me deja accesar aunq le ingrese correctamente el usuario y la contraseña. les dejo el enlace desde donde lo baje para que pueden ver el problema http://www.phpwebcommerce.com/shopping-cart-source-code.php

Gracias de antemano
  #2 (permalink)  
Antiguo 04/11/2008, 16:43
Avatar de bacdavi  
Fecha de Ingreso: junio-2006
Ubicación: http://localhost/
Mensajes: 351
Antigüedad: 17 años, 10 meses
Puntos: 7
Respuesta: Ayuda con carrito de compra

Le has hecho alguna modificación al Código Fuente??
Puede que sea un problema dentro de la DB en mysql, y que depronto no reconozca las contraseñas encriptadas....
  #3 (permalink)  
Antiguo 04/11/2008, 16:48
Avatar de Carxl
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: Bogotá
Mensajes: 2.993
Antigüedad: 17 años, 8 meses
Puntos: 70
Respuesta: Ayuda con carrito de compra

Hola pacognovellino, cómo vas??

Qué tipo de error te arroja?
__________________
Hay 10 tipos de personas, los que entienden binario y los que no. (Anónimo)
www.programandoweb.com
  #4 (permalink)  
Antiguo 04/11/2008, 17:03
 
Fecha de Ingreso: noviembre-2008
Mensajes: 23
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Ayuda con carrito de compra

no le hice ningun cambio Bacdavi, al ver q no reconocia a los usuarios ingrese uno con el phpmyadmin sin contraseña encriptada y aun asi no reconoce
Gracias Bacdavi
no puedo ingresar a la seccion de administrador para agregar productos o categorias. Revise la base de datos con phpmyadmin para ver el usuario y contraseña (admin, admin) y aun asi no me deja ingresar
Gracias Carxl
  #5 (permalink)  
Antiguo 04/11/2008, 20:00
Avatar de bacdavi  
Fecha de Ingreso: junio-2006
Ubicación: http://localhost/
Mensajes: 351
Antigüedad: 17 años, 10 meses
Puntos: 7
Respuesta: Ayuda con carrito de compra

Pues si un codigo contra el que comparar no te puedo ayudar mucho!
Lo que sugiero es que instales de nuevo tu carrito! y si no podes usar ZenCart es muy bueno
  #6 (permalink)  
Antiguo 04/11/2008, 20:20
 
Fecha de Ingreso: noviembre-2008
Mensajes: 23
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Ayuda con carrito de compra

el codigo fuente esta en este link, http://www.phpwebcommerce.com/shopping-cart-source-code.php, es muy facil de costumizar y realmente quisiera poder hacerlo funcionar
Gracias Bacdavi
  #7 (permalink)  
Antiguo 04/11/2008, 20:25
Avatar de bacdavi  
Fecha de Ingreso: junio-2006
Ubicación: http://localhost/
Mensajes: 351
Antigüedad: 17 años, 10 meses
Puntos: 7
Respuesta: Ayuda con carrito de compra

Cita:
Iniciado por pacognovellino Ver Mensaje
el codigo fuente esta en este link, http://www.phpwebcommerce.com/shopping-cart-source-code.php, es muy facil de costumizar y realmente quisiera poder hacerlo funcionar
Gracias Bacdavi
Hey te despliega algún error??
por lo que veo debería funcionar al 100!
  #8 (permalink)  
Antiguo 04/11/2008, 20:30
 
Fecha de Ingreso: noviembre-2008
Mensajes: 23
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Ayuda con carrito de compra

al trater de ingresar a la parte de admin/login.php te pide el usuario y la contraseña al ingresar el usuario: admin con contraseña: admin no puedo accesar a la pagina para administrar las categorias y porductos
  #9 (permalink)  
Antiguo 04/11/2008, 20:32
Avatar de bacdavi  
Fecha de Ingreso: junio-2006
Ubicación: http://localhost/
Mensajes: 351
Antigüedad: 17 años, 10 meses
Puntos: 7
Respuesta: Ayuda con carrito de compra

comprobá que la conexión este establecida por medio de mysql; puede que el formulario en el que se procesa la solicitud de logueo no este bien definido!
  #10 (permalink)  
Antiguo 04/11/2008, 20:39
 
Fecha de Ingreso: noviembre-2008
Mensajes: 23
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Ayuda con carrito de compra

este es el código de la pagina login.php

Código PHP:
<?php
require_once '../library/config.php';
require_once 
'./library/functions.php';

$errorMessage '&nbsp;';

if (isset(
$_POST['txtUserName'])) {
    
$result doLogin();
    
    if (
$result != '') {
        
$errorMessage $result;
    }
}

?>
<html>
<head>
<title>Shop Admin - Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="include/admin.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="1" class="graybox">
 <tr> 
  <td><img src="include/banner-top.gif" width="750" height="75"></td>
 </tr>
 <tr> 
  <td valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="20">
    <tr> 
     <td class="contentArea"> <form method="post" name="frmLogin" id="frmLogin">
       <p>&nbsp;</p>
       <table width="350" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#336699" class="entryTable">
        <tr id="entryTableHeader"> 
         <td>:: Admin Login ::</td>
        </tr>
        <tr> 
         <td class="contentArea"> 
         <div class="errorMessage" align="center"><?php echo $errorMessage?></div>
          <table width="100%" border="0" cellpadding="2" cellspacing="1" class="text">
           <tr align="center"> 
            <td colspan="3">&nbsp;</td>
           </tr>
           <tr class="text"> 
            <td width="100" align="right">User Name</td>
            <td width="10" align="center">:</td>
            <td><input name="txtUserName" type="text" class="box" id="txtUserName" value="admin" size="10" maxlength="20"></td>
           </tr>
           <tr> 
            <td width="100" align="right">Password</td>
            <td width="10" align="center">:</td>
            <td><input name="txtPassword" type="password" class="box" id="txtPassword" value="admin" size="10"></td>
           </tr>
           <tr> 
            <td colspan="2">&nbsp;</td>
            <td><input name="btnLogin" type="submit" class="box" id="btnLogin" value="Login"></td>
           </tr>
          </table></td>
        </tr>
       </table>
       <p>&nbsp;</p>
      </form></td>
    </tr>
   </table></td>
 </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
  #11 (permalink)  
Antiguo 04/11/2008, 23:08
 
Fecha de Ingreso: noviembre-2008
Mensajes: 23
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Ayuda con carrito de compra

gracias por su ayuda, encontre el error, esta en el archivo functions.php dentro de la carpeta de admin. Les dejo el código por si quieren utilizar la carretilla
Código PHP:
<?php

/*
    Check if a session user id exist or not. If not set redirect
    to login page. If the user session id exist and there's found
    $_GET['logout'] in the query string logout the user
*/
function checkUser()
{
    
// if the session id is not set, redirect to login page
    
if (!isset($_SESSION['plaincart_user_id'])) {
        
header('Location: ' WEB_ROOT 'admin/login.php');
        exit;
    }
    
    
// the user want to logout
    
if (isset($_GET['logout'])) {
        
doLogout();
    }
}

/*
    
*/
function doLogin()
{
    
// if we found an error save the error message in this variable
    
$errorMessage '';
    
    
$userName $_POST['txtUserName'];
    
$password $_POST['txtPassword'];
    
    
// first, make sure the username & password are not empty
    
if ($userName == '') {
        
$errorMessage 'ingrese su nombre de usuario';
    } else if (
$password == '') {
        
$errorMessage 'ingrese su contraseña';
    } else {
        
// check the database and see if the username and password combo do match
        
$sql "SELECT user_id
                FROM tbl_user 
                WHERE user_name = '$userName' AND user_password = '$password'"
;
        
$result dbQuery($sql);
    
        if (
dbNumRows($result) == 1) {
            
$row dbFetchAssoc($result);
            
$_SESSION['plaincart_user_id'] = $row['user_id'];
            
            
// log the time when the user last login
            
$sql "UPDATE tbl_user 
                    SET user_last_login = NOW() 
                    WHERE user_id = '{$row['user_id']}'"
;
            
dbQuery($sql);

            
// now that the user is verified we move on to the next page
            // if the user had been in the admin pages before we move to
            // the last page visited
            
if (isset($_SESSION['login_return_url'])) {
                
header('Location: ' $_SESSION['login_return_url']);
                exit;
            } else {
                
header('Location: index.php');
                exit;
            }
        } else {
            
$errorMessage 'Error! verifique los datos';
        }        
            
    }
    
    return 
$errorMessage;
}

/*
    Logout a user
*/
function doLogout()
{
    if (isset(
$_SESSION['plaincart_user_id'])) {
        unset(
$_SESSION['plaincart_user_id']);
        
session_unregister('plaincart_user_id');
    }
        
    
header('Location: login.php');
    exit;
}


/*
    Generate combo box options containing the categories we have.
    if $catId is set then that category is selected
*/
function buildCategoryOptions($catId 0)
{
    
$sql "SELECT cat_id, cat_parent_id, cat_name
            FROM tbl_category
            ORDER BY cat_id"
;
    
$result dbQuery($sql) or die('Cannot get Product. ' mysql_error());
    
    
$categories = array();
    while(
$row dbFetchArray($result)) {
        list(
$id$parentId$name) = $row;
        
        if (
$parentId == 0) {
            
// we create a new array for each top level categories
            
$categories[$id] = array('name' => $name'children' => array());
        } else {
            
// the child categories are put int the parent category's array
            
$categories[$parentId]['children'][] = array('id' => $id'name' => $name);    
        }
    }    
    
    
// build combo box options
    
$list '';
    foreach (
$categories as $key => $value) {
        
$name     $value['name'];
        
$children $value['children'];
        
        
$list .= "<optgroup label=\"$name\">"
        
        foreach (
$children as $child) {
            
$list .= "<option value=\"{$child['id']}\"";
            if (
$child['id'] == $catId) {
                
$list.= " selected";
            }
            
            
$list .= ">{$child['name']}</option>\r\n";
        }
        
        
$list .= "</optgroup>";
    }
    
    return 
$list;
}

/*
    If you want to be able to add products to the first level category
    replace the above function with the one below
*/
/*

function buildCategoryOptions($catId = 0)
{
    $sql = "SELECT cat_id, cat_parent_id, cat_name
            FROM tbl_category
            ORDER BY cat_id";
    $result = dbQuery($sql) or die('Cannot get Product. ' . mysql_error());
    
    $categories = array();
    while($row = dbFetchArray($result)) {
        list($id, $parentId, $name) = $row;
        
        if ($parentId == 0) {
            // we create a new array for each top level categories
            $categories[$id] = array('name' => $name, 'children' => array());
        } else {
            // the child categories are put int the parent category's array
            $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name);    
        }
    }    
    
    // build combo box options
    $list = '';
    foreach ($categories as $key => $value) {
        $name     = $value['name'];
        $children = $value['children'];
        
        $list .= "<option value=\"$key\"";
        if ($key == $catId) {
            $list.= " selected";
        }
            
        $list .= ">$name</option>\r\n";

        foreach ($children as $child) {
            $list .= "<option value=\"{$child['id']}\"";
            if ($child['id'] == $catId) {
                $list.= " selected";
            }
            
            $list .= ">&nbsp;&nbsp;{$child['name']}</option>\r\n";
        }
    }
    
    return $list;
}
*/

/*
    Create a thumbnail of $srcFile and save it to $destFile.
    The thumbnail will be $width pixels.
*/
function createThumbnail($srcFile$destFile$width$quality 75)
{
    
$thumbnail '';
    
    if (
file_exists($srcFile)  && isset($destFile))
    {
        
$size        getimagesize($srcFile);
        
$w           number_format($width0',''');
        
$h           number_format(($size[1] / $size[0]) * $width0',''');
        
        
$thumbnail =  copyImage($srcFile$destFile$w$h$quality);
    }
    
    
// return the thumbnail file name on sucess or blank on fail
    
return basename($thumbnail);
}

/*
    Copy an image to a destination file. The destination
    image size will be $w X $h pixels
*/
function copyImage($srcFile$destFile$w$h$quality 75)
{
    
$tmpSrc     pathinfo(strtolower($srcFile));
    
$tmpDest    pathinfo(strtolower($destFile));
    
$size       getimagesize($srcFile);

    if (
$tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg")
    {
       
$destFile  substr_replace($destFile'jpg', -3);
       
$dest      imagecreatetruecolor($w$h);
       
imageantialias($destTRUE);
    } elseif (
$tmpDest['extension'] == "png") {
       
$dest imagecreatetruecolor($w$h);
       
imageantialias($destTRUE);
    } else {
      return 
false;
    }

    switch(
$size[2])
    {
       case 
1:       //GIF
           
$src imagecreatefromgif($srcFile);
           break;
       case 
2:       //JPEG
           
$src imagecreatefromjpeg($srcFile);
           break;
       case 
3:       //PNG
           
$src imagecreatefrompng($srcFile);
           break;
       default:
           return 
false;
           break;
    }

    
imagecopyresampled($dest$src0000$w$h$size[0], $size[1]);

    switch(
$size[2])
    {
       case 
1:
       case 
2:
           
imagejpeg($dest,$destFile$quality);
           break;
       case 
3:
           
imagepng($dest,$destFile);
    }
    return 
$destFile;

}

/*
    Create the paging links
*/
function getPagingNav($sql$pageNum$rowsPerPage$queryString '')
{
    
$result  mysql_query($sql) or die('Error, query failed. ' mysql_error());
    
$row     mysql_fetch_array($resultMYSQL_ASSOC);
    
$numrows $row['numrows'];
    
    
// how many pages we have when using paging?
    
$maxPage ceil($numrows/$rowsPerPage);
    
    
$self $_SERVER['PHP_SELF'];
    
    
// creating 'previous' and 'next' link
    // plus 'first page' and 'last page' link
    
    // print 'previous' link only if we're not
    // on page one
    
if ($pageNum 1)
    {
        
$page $pageNum 1;
        
$prev " <a href=\"$self?page=$page{$queryString}\">[Prev]</a> ";
    
        
$first " <a href=\"$self?page=1{$queryString}\">[First Page]</a> ";
    }
    else
    {
        
$prev  ' [Prev] ';       // we're on page one, don't enable 'previous' link
        
$first ' [First Page] '// nor 'first page' link
    
}
    
    
// print 'next' link only if we're not
    // on the last page
    
if ($pageNum $maxPage)
    {
        
$page $pageNum 1;
        
$next " <a href=\"$self?page=$page{$queryString}\">[Next]</a> ";
    
        
$last " <a href=\"$self?page=$maxPage{$queryString}{$queryString}\">[Last Page]</a> ";
    }
    else
    {
        
$next ' [Next] ';      // we're on the last page, don't enable 'next' link
        
$last ' [Last Page] '// nor 'last page' link
    
}
    
    
// return the page navigation link
    
return $first $prev " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " $next $last
}
?>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:09.