Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Suggestions Box for xcart product detail page :)

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 01-27-2004, 04:18 PM
 
deniz deniz is offline
 

Advanced Member
  
Join Date: Sep 2003
Posts: 70
 

Default Suggestions Box for xcart product detail page :)

You can check a copy of running version from site :
http://www.bookglobal.net/xcart/customer/product.php?productid=622

It works simple PHP ,

first make customer/suggestions.tpl
Code:
{capture name=dialog} <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td width="100%" bgcolor="#EAF4FF"> Your comments can help make our site better for everyone. If you've found something incorrect, broken, or frustrating on this page, let us know so that we can improve it. Please note that we are unable to respond directly to suggestions made via this form. If you need help with an order, please <a href="http://www.bookglobal.net/xcart/customer/help.php?section=contactus&mode=update">contact Customer Service </a>. Which subjects that you can send us about?: <table cellspacing="2" cellpadding="0"> <tr> <td rowspan="2"></td> <td></td> </tr> <tr> <td>Product information is missing important details. </td> </tr> <tr> <td></td> <td>Product information is incorrect.</td> </tr> <tr> <td></td> <td>The page contains typographical errors. </td> </tr> <tr> <td></td> <td>The page takes too long to load. </td> </tr> <tr> <td></td> <td>The page has a software bug in it. </td> </tr> <tr> <td></td> <td>Suggestion want to be in page. </td> </tr> <tr> <td></td> <td>General Suggestions </td> </tr> </table> Comments or Examples: Examples: Missing information such as dimensions and model number, typos, inaccuracies, etc. <form name="form1" method="POST" action="[b]http://www.yoursite.com/xcart/suggestions/index.php[/b]" target="_blank"> <div align="center"><input type="hidden" name="id"> <textarea name="suggestions" cols="75" rows="5" id="suggestions"></textarea> <input name="name" type="text" id="name" value="Please enter your name here" size="55"> <input type="submit" name="Submit" value="Submit"> </div> <input type="hidden" name="MM_insert" value="form1"> </form></td> </tr> </table> {/capture} { include file="dialog.tpl" title="Suggestion Box" content=$smarty.capture.dialog extra="width=100%"}

After that edit customer/main/product.tpl

add the following code at the bottom.

Code:
{include file="customer/suggestions.tpl" }

And after this make index.php file under your web site
the code configured to http://www.yoursite.com/xcart/suggestions/index.php please configure it as your site address before run.

index.php

Code:
<?php require_once('Connections/db_connect.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO suggestions (id, suggestion, name) VALUES (%s, %s, %s)", GetSQLValueString($_POST['id'], "int"), GetSQLValueString($_POST['suggestions'], "text"), GetSQLValueString($_POST['name'], "text")); mysql_select_db($database_db_connect, $db_connect); $Result1 = mysql_query($insertSQL, $db_connect) or die(mysql_error()); $insertGoTo = "thanks.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td width="100%" bgcolor="#EAF4FF"> Your comments can help make our site better for everyone. If you've found something incorrect, broken, or frustrating on this page, let us know so that we can improve it. Please note that we are unable to respond directly to suggestions made via this form. If you need help with an order, please <a href="http://www.bookglobal.net/xcart/customer/help.php?section=contactus&mode=update">contact Customer Service </a>. Which subjects that you can send us about?: <table cellspacing="2" cellpadding="0"> <tr> <td rowspan="2"></td> <td></td> </tr> <tr> <td>Product information is missing important details. </td> </tr> <tr> <td></td> <td>Product information is incorrect.</td> </tr> <tr> <td></td> <td>The page contains typographical errors. </td> </tr> <tr> <td></td> <td>The page takes too long to load. </td> </tr> <tr> <td></td> <td>The page has a software bug in it. </td> </tr> <tr> <td></td> <td>Suggestion want to be in page. </td> </tr> <tr> <td></td> <td>General Suggestions </td> </tr> </table> Comments or Examples: Examples: Missing information such as dimensions and model number, typos, inaccuracies, etc. <form name="form1" method="POST" action="<?php echo $editFormAction; ?>" target="_blank"> <div align="center"> <input type="hidden" name="id"> <textarea name="suggestions" cols="100" rows="5" id="suggestions"></textarea> <input name="name" type="text" id="name" value="Please enter your name here" size="55"> <input type="submit" name="Submit" value="Submit"> </div> <input type="hidden" name="MM_insert" value="form1"> </form></td> </tr> </table> </body> </html>

and make the thanks.php

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Bookglobal.net Suggestions</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } --> </style></head> <body> <div align="center"> <table width="605" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="605" height="57" valign="top">[img]images/logo_phpBB.gif[/img]</td> </tr> <tr> <td height="19" valign="top"><div align="center">Dear customer thanks for helping us to make our site better for everyone.</div></td> </tr> <tr> <td height="20"></td> </tr> <tr> <td height="19" valign="top"> <div align="center">Please use &quot;Session9876 &quot; 10% discount code in your orders. </div></td> </tr> <tr> <td height="29"></td> </tr> <tr> <td height="21" valign="top"><div align="center">Close this window</div></td> </tr> </table> </div> </body> </html>

and if you wish to check suggestions via admin panel

make admin/admin.php

Code:
<?php require_once('../Connections/db_connect.php'); ?> <?php // *** Validate request to login to this site. session_start(); $loginFormAction = $_SERVER['PHP_SELF']; if (isset($accesscheck)) { $GLOBALS['PrevUrl'] = $accesscheck; session_register('PrevUrl'); } if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "show.php"; $MM_redirectLoginFailed = "failed.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_db_connect, $db_connect); $LoginRS__query=sprintf("SELECT username, password FROM admin WHERE username='%s' AND password='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $db_connect) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; //register the session variables session_register("MM_Username"); session_register("MM_UserGroup"); if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Admin Panel</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="skin1.css" rel="stylesheet" type="text/css"> </head> <body> <div align="center"> <table width="662" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="662" height="12" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="662" height="12" valign="top" class="CustomerMessage">Customer Suggestion Admin Panel </td> </tr> </table></td> </tr> <tr> <td height="13" valign="top"><form name="form1" method="POST" action="<?php echo $loginFormAction; ?>"> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td colspan="4">L&uuml;tfen şifrenizi giriniz: </td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td>Username:</td> <td><input name="username" type="text" id="username"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td>Password:</td> <td><input name="password" type="password" id="password"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td><input type="submit" name="Submit" value="Tamam"></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </table> </form></td> </tr> <tr> <td height="12"></td> </tr> </table> </div> </body> </html>

and... last one show.php

Code:
<?php require_once('../Connections/db_connect.php'); ?> <?php //initialize the session session_start(); // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles session_unregister('MM_Username'); session_unregister('MM_UserGroup'); $logoutGoTo = "index.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } if ((isset($_GET['delete'])) && ($_GET['delete'] != "")) { $deleteSQL = sprintf("DELETE FROM suggestions WHERE id=%s", GetSQLValueString($_GET['delete'], "int")); mysql_select_db($database_db_connect, $db_connect); $Result1 = mysql_query($deleteSQL, $db_connect) or die(mysql_error()); $deleteGoTo = "confirmation.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } mysql_select_db($database_db_connect, $db_connect); $query_suggest_action = "SELECT * FROM suggestions ORDER BY id DESC"; $suggest_action = mysql_query($query_suggest_action, $db_connect) or die(mysql_error()); $row_suggest_action = mysql_fetch_assoc($suggest_action); $totalRows_suggest_action = mysql_num_rows($suggest_action); ?> <link href="skin1.css" rel="stylesheet" type="text/css"> <table width="740" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="19" colspan="4" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="740" height="19" valign="top" bgcolor="#F4F4F4"><strong class="ProductDetailsTitle">Customer Suggestions Mod . Admin Panel by Deniz U. DERELİ :) ц┤yky?[/b]</td> </tr> </table></td> </tr> <tr> <td height="22" colspan="4"></td> </tr> <?php if ($totalRows_suggest_action > 0) { // Show if recordset not empty ?> <tr class="DialogBorder"> <td width="109" height="10" valign="top"><div align="center">Suggest Id </div></td> <td width="171" valign="top">Name</td> <td width="407" valign="top">Suggestion</td> <td width="53" valign="top"><div align="center">Action</div></td> </tr> <?php } // Show if recordset not empty ?> <?php do { ?> <tr class="inpGeneral"> <td width="109" height="5" valign="top"><?php echo $row_suggest_action['id']; ?></td> <td valign="top"><?php echo $row_suggest_action['name']; ?></td> <td valign="top"><?php echo $row_suggest_action['suggestion']; ?></td> <td width="53" valign="top"><div align="center">Delete</div></td> </tr> <tr class="inpGeneral"> <td height="4" colspan="4" valign="top"><hr></td> </tr> <?php } while ($row_suggest_action = mysql_fetch_assoc($suggest_action)); ?> <tr> <td height="30" colspan="4"><div align="center"> <?php if ($totalRows_suggest_action == 0) { // Show if recordset empty ?> Henц╪z bir ц╤neri veya gц╤rц╪? bulunmamaktadyr. <?php } // Show if recordset empty ?> </div></td> </tr> </table> <?php mysql_free_result($suggest_action); ?>

After all of them we have to configure our mysql database.

we have to make a db connection php file before run ,

make file connection/db_connection.php

Code:
<?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_db_connect = "localhost"; $database_db_connect = "suggestions"; $username_db_connect = "root"; $password_db_connect = ""; $db_connect = mysql_pconnect($hostname_db_connect, $username_db_connect, $password_db_connect) or trigger_error(mysql_error(),E_USER_ERROR); ?>

Please change details , db name and user name as yours

and run SQL command to the your DB

Code:
CREATE TABLE admin ( username varchar(255) default NULL, password varchar(255) default NULL, KEY username (username) ) TYPE=MyISAM; INSERT INTO admin VALUES ('master', 'master'); CREATE TABLE suggestions ( id tinyint(3) NOT NULL auto_increment, suggestion text, name varchar(255) default NULL, KEY id (id) ) TYPE=MyISAM;

On first use your usernama and password is master,master

best wishes...[/code]
Reply With Quote
  #2  
Old 01-27-2004, 05:48 PM
  leon's Avatar 
leon leon is offline
 

X-Wizard
  
Join Date: Mar 2003
Location: Costa Rica
Posts: 1,213
 

Default

Thanks, Im gonna test it, but you should of posted this in Custom Mods.

Great mod.
__________________
It doesn\'t matter what is done... it is how it is done.
=============================
XCart Version: 3.5.3 -> Dmcigars.com
XCart Version: 4.1.3....
Reply With Quote
  #3  
Old 01-29-2004, 08:57 PM
 
deniz deniz is offline
 

Advanced Member
  
Join Date: Sep 2003
Posts: 70
 

Default upps!

Ok may site admin move this topic to this
Reply With Quote
  #4  
Old 01-29-2004, 09:54 PM
  DataViking's Avatar 
DataViking DataViking is offline
 

eXpert
  
Join Date: Jan 2003
Location: Las Vegas, NV
Posts: 361
 

Default

nice
__________________
Web Design Web Design and Custom X-Cart Projects

http://www.dataviking.com

Mention the forums for discounts!
x-cart Version 4.1.8
Reply With Quote
  #5  
Old 01-30-2004, 06:09 AM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Thanks for posting this great mod and detailing all of the steps so nicely.

Much appreciated.

Your site is very nice and tight. I like it.
Reply With Quote
  #6  
Old 01-30-2004, 10:16 PM
 
curpier curpier is offline
 

Advanced Member
  
Join Date: Sep 2003
Posts: 38
 

Default

I'm having some trouble getting this mod to work.

I've followed the above directions ... replacing my web address, etc.

It looks fine, but when I click the submit button, I get a page not found ... it puts this in the address bar:

http://www.curpiermotorsport.com/xcart/customer/http://www.curpiermotorsport.com/xcart/suggestions/index.php

You can test it here:

http://www.curpiermotorsport.com/xcart/customer/product.php?productid=18&cat=&page=&xid=d0f6f62bf5 a1690ea208b05f1a17dc82

If I go directly to the index.php it gives me this error:

Fatal error: Failed opening required 'Connections/db_connect.php' (include_path='./:/usr/local/lib/php') in /home/adamc/curpiermotorsport-www/xcart/suggestions/index.php on line 1

I replaced my database information if the db_connection.php file in here:

$hostname_db_connect = "localhost";
$database_db_connect = "suggestions";
$username_db_connect = "root";
$password_db_connect = "";

I also patched the database.

Any idea why this happens?

Last, in the directions it say's to make a /connection/db_connection.php file. Should it be instead: /Connections/db_connect.php


Adam
3.4.9
Reply With Quote
  #7  
Old 01-30-2004, 11:52 PM
 
deniz deniz is offline
 

Advanced Member
  
Join Date: Sep 2003
Posts: 70
 

Default

OK I have look at this and found an error,

You have to change line which is

"
http://www.curpiermotorsport.com/xcart/customer/http://www.curpiermotorsport.com/xcart/suggestions/index.php"

"

to http://www.curpiermotorsport.com/xcart/suggestions/index.php


in the form action of TPL file.

Regards
Reply With Quote
  #8  
Old 01-30-2004, 11:53 PM
 
deniz deniz is offline
 

Advanced Member
  
Join Date: Sep 2003
Posts: 70
 

Default

Opps.. and you have to change db_connect.php file as your details.

Your database name and username
Reply With Quote
  #9  
Old 01-31-2004, 08:46 AM
 
curpier curpier is offline
 

Advanced Member
  
Join Date: Sep 2003
Posts: 38
 

Default

Okay, I fixed the first problem in the suggestions.tpl.

But I'm still getting this error after I click "submit"

Fatal error: Failed opening required 'Connections/db_connect.php' (include_path='./:/usr/local/lib/php') in /home/adamc/curpiermotorsport-www/xcart/suggestions/index.php on line 1

It seems like it's not connecting to the database?

I did fix the db_connect.php file. It now resides in the Connections folder in the xcart directory.

Here's what I replaced in the db_connect.php

Quote:
<?
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_db_connect = 'localhost';
$database_db_connect = 'My Datebase Name';
$username_db_connect ='My Database Username';
$password_db_connect = 'My Database Password';
$db_connect = mysql_pconnect($hostname_db_connect, $username_db_connect, $password_db_connect) or trigger_error(mysql_error(),E_USER_ERROR);
?>

Is this correct?

Also, when I go to the admin page, I get these errors:

Warning: Cannot send session cookie - headers already sent by (output started at /home/adamc/curpiermotorsport-www/xcart/admin/admin.php:2) in /home/adamc/curpiermotorsport-www/xcart/admin/admin.php on line 4

Warning: Cannot send session cache limiter - headers already sent (output started at /home/adamc/curpiermotorsport-www/xcart/admin/admin.php:2) in /home/adamc/curpiermotorsport-www/xcart/admin/admin.php on line 4
Reply With Quote
  #10  
Old 02-01-2004, 10:41 AM
 
deniz deniz is offline
 

Advanced Member
  
Join Date: Sep 2003
Posts: 70
 

Default

I guess you have pasted wrong codes to TPL file. TPL file must be basic HTML tags not the PHP tags. I offer you to re-start step by step.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:41 PM.

   

 
X-Cart forums © 2001-2020