View Single Post
  #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