Help Desk Software & Beyond
August 22, 2017, 02:00:59 AM *
Welcome, Guest. Please login or register.
To post messages you need to register. We apologize for inconvenience, but this is to prevent spam.
Registration is instant (no email verification) and we do not ask for any personal information.

Login with username, password and session length
News: Welcome to Help Desk Software forum!
 
   Home   Help Search Login Register  
Pages: [1] 2 3 ... 5
  Print  
Author Topic: Sharing login info with a PHP - Smarty - MySQL app  (Read 63829 times)
loneguard
Jr. Member
**

Karma: 0
Posts: 98


View Profile
« on: October 04, 2007, 06:02:13 PM »

I was wondering just how much modifications it would take to use the info of a customer logged in to my webiste prefilled in the Contact Customer Service form.
The webiste is PHP-Smarty-MySQL driven. Any ideas?
Logged
Sparky
Moderator
Hero Member
*****

Karma: 85
Posts: 2,275


stop pushing all those buttons


View Profile
« Reply #1 on: October 04, 2007, 06:08:25 PM »

I was wondering just how much modifications it would take to use the info of a customer logged in to my webiste prefilled in the Contact Customer Service form.
The webiste is PHP-Smarty-MySQL driven. Any ideas?

Is the relevant customer information available to your pages?

Can you populate hidden variable values and use Javascript to copy this information into your Customer Contact Form?

Better yet, just populate the values of the text boxes directly when the New Ticket page loads.
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
loneguard
Jr. Member
**

Karma: 0
Posts: 98


View Profile
« Reply #2 on: October 04, 2007, 06:50:40 PM »

Oh, I think you're giving me too much credit, my friend  Embarrassed I'm not a programmer. Last time I was this close to cgi, html and PHP was 10 years ago in college...
Let's see - I don't think I can populate directly from the text boxes on my site, because when a customer logs in, they enter a username and password. I need a Firstname, Lastname and an Email address to populate the boxes in the TTX form.
I think the values for those variables are storred in the sessions data in my website's MySQL database, but I may be wrong.
I think I'd rather pay somebody to do the dirty work  Smiley
Logged
Sparky
Moderator
Hero Member
*****

Karma: 85
Posts: 2,275


stop pushing all those buttons


View Profile
« Reply #3 on: October 04, 2007, 06:59:53 PM »

Well then to answer your first question I don't think any modifications to TTX would be required at all.

You need to figure out how to get "first name", "last name", and "email address" out of your MySQL and onto any HTML page.  I'm not a MySQL expert but would expect this to be fairly routine.

Once you figure that out, you'd only need to modify the TTX newticket.html template to receive these three things.

They can be stored in hidden fields to be manipulated with Javascript or perhaps dropped directly into the text fields.

<input type=hidden name=first value="firstnamefromMySQL">

If you can figure out the first part (getting the three bits from MySQL into a HTML page), I'll happily share with you how to do the rest.
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
Sparky
Moderator
Hero Member
*****

Karma: 85
Posts: 2,275


stop pushing all those buttons


View Profile
« Reply #4 on: October 04, 2007, 07:04:45 PM »

Here's a new idea.

We can write a Javascript that stores first, last, and email, into a cookie for retrieval when the newticket page is accessed.

Do you execute any javascript code on your login page when the person logs in?

Is your login page and the TTX new ticket page on the same domain name?  If yes, this is a simple matter using a cookie.

Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
loneguard
Jr. Member
**

Karma: 0
Posts: 98


View Profile
« Reply #5 on: October 04, 2007, 09:56:41 PM »

The TTX and secure login page are on the same domain, www.aquasanacanada.com
Not only that, but they use the same MySQL database. The PHP code is Smarty Template driven.
My secure_login.php has, among other code, this piece of code:

if (!empty($HTTP_GET_VARS[$XCART_SESSION_NAME])) {
   if (empty($HTTP_COOKIE_VARS[$XCART_SESSION_NAME]))
      $HTTP_COOKIE_VARS[$XCART_SESSION_NAME] = $XCARTSESSID;
   func_header_location("secure_login.php");
}

The 'Submit' button uses Javascript.
I hope this gives you some idea.

Thanks,

LG
Logged
Sparky
Moderator
Hero Member
*****

Karma: 85
Posts: 2,275


stop pushing all those buttons


View Profile
« Reply #6 on: October 04, 2007, 09:59:19 PM »

Cut 'n paste the full Javascript function that the button calls.
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
loneguard
Jr. Member
**

Karma: 0
Posts: 98


View Profile
« Reply #7 on: October 04, 2007, 10:55:11 PM »

Sparky672 - I'm a little confused by my template/php combinations, so let me paste the secure_login.tpl here:
***THE RED PART HAS TO DO WITH 'REMEMBER ME' MOD (CHECKBOX) AND IT WASN'T A PART OF THE ORIGINAL LOGIN PAGE CODE***
{* $Id: secure_login_form.tpl,v 1.6.2.1 2004/08/06 11:02:17 max Exp $ *}
{$lng.txt_secure_login_form}
<P>
{capture name=dialog}
{literal}
<script LANGUAGE="JavaScript">
<!--
function confirmSubmit2() {
if (document.secureform.remember.checked == true) {
alert("{/literal}{$lng.txt_remember_me_warning}{literal}");
document.authform.submit();
}
}
// -->
</script>
{/literal}
<TABLE border="0">
<FORM action="{$https_location}/include/login.php" method="post" name=secureform>
<TR>
<TD height="10" width="78" class="FormButton">{$lng.lbl_username}</TD>
<TD width="10" height="10"><FONT class="Star">*</FONT></TD>
<TD width="282" height="10">
<INPUT type="text" name="username" size="30">
</TD>
</TR>
<TR>
<TD height="10" width="78" class="FormButton">{$lng.lbl_password}</TD>
<TD width="10" height="10"><FONT class="Star">*</FONT></TD>
<TD width="282" height="10">
<INPUT type="password" name="password" size="30">
{if $active_modules.Simple_Mode ne "" and $usertype ne "C"}
<INPUT type="hidden" name="usertype" value="P">
{else}
<INPUT type="hidden" name="usertype" value="{$usertype}">
{/if}
<INPUT type="hidden" name="redirect" value="{$redirect}">
{if $redirect ne "admin"}
<br>
<input type="checkbox" name="remember" value="Y">{$lng.lbl_remember_me}
{else}
<input type="hidden" name="remember" value="">
{/if}
<INPUT type="hidden" name="mode" value="login">
</TD>
</TR>
<TR>
<TD height="10" width="78" class="FormButton"></TD>
<TD width="10" height="10">&nbsp;</TD>
<TD width="282" height="10" class="ErrorMessage">
</TD>
</TR>
<TR>
<TD height="10" width="78" class="FormButton"></TD>
<TD width="10" height="10" class="FormButton">&nbsp;</TD>
<TD width="282" height="10">
{if $js_enabled}
{include file="buttons/submit.tpl" href="javascript:document.secureform.submit();" js_to_href="Y" onclick="confirmSubmit2()"}
{else}
{include file="submit_wo_js.tpl" value=$lng.lbl_submit}
{/if}
</TD>
</TR>
</FORM>
</TABLE>
<P>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_secure_login_form content=$smarty.capture.dialog extra="width=100%"}


and my secure_login.php code

#
# $Id: secure_login.php,v 1.1.2.4 2006/02/16 07:41:39 max Exp $
#

require "./auth.php";

if (!empty($HTTP_GET_VARS[$XCART_SESSION_NAME])) {
   if (empty($HTTP_COOKIE_VARS[$XCART_SESSION_NAME]))
      $HTTP_COOKIE_VARS[$XCART_SESSION_NAME] = $XCARTSESSID;
   func_header_location("secure_login.php");
}

require $xcart_dir."/include/categories.php";

$location[] = array(func_get_langvar_by_name("lbl_authentication"), "");

if($active_modules["Manufacturers"])
    include $xcart_dir."/modules/Manufacturers/customer_manufacturers.php";

#
# Assign Smarty variables and show template
#
$smarty->assign("main", "secure_login_form");

# Assign the current location line
$smarty->assign("location", $location);

func_display("customer/home.tpl",$smarty);
?>


If you need anything else that the code references, please let me know.
Thanks
Logged
Sparky
Moderator
Hero Member
*****

Karma: 85
Posts: 2,275


stop pushing all those buttons


View Profile
« Reply #8 on: October 05, 2007, 12:02:00 PM »

Below in red is code that will save first name, last name, and email address in three cookies when the submit button is pressed.  However, it will not function because I don't see any HTML for the corresponding text boxes in your page below.  I was under the impression that this was the place where they entered that information.

Maybe you can figure out if you have PHP macros available that will drop in the required name/email on a later page after login?

Quote
{* $Id: secure_login_form.tpl,v 1.6.2.1 2004/08/06 11:02:17 max Exp $ *}
{$lng.txt_secure_login_form}
<P>
{capture name=dialog}
{literal}
<script LANGUAGE="JavaScript">
<!--
function confirmSubmit2() {
var myname1 = document.getElementById('firstname').value;
var myname2 = document.getElementById('lastname').value;
var email = document.getElementById('email').value;
document.cookie = "firstname="+myname1+";path=/;";
document.cookie = "lastname="+myname2+";path=/;";
document.cookie = "email="+email+";path=/;";

if (document.secureform.remember.checked == true) {
alert("{/literal}{$lng.txt_remember_me_warning}{literal}");
document.authform.submit();
}
}
// -->
</script>{/literal}
<TABLE border="0">
<FORM action="{$https_location}/include/login.php" method="post" name=secureform>
<TR>
<TD height="10" width="78" class="FormButton">{$lng.lbl_username}</TD>
<TD width="10" height="10"><FONT class="Star">*</FONT></TD>
<TD width="282" height="10">
<INPUT type="text" name="username" size="30">
</TD>
</TR>
<TR>
<TD height="10" width="78" class="FormButton">{$lng.lbl_password}</TD>
<TD width="10" height="10"><FONT class="Star">*</FONT></TD>
<TD width="282" height="10">
<INPUT type="password" name="password" size="30">
{if $active_modules.Simple_Mode ne "" and $usertype ne "C"}
<INPUT type="hidden" name="usertype" value="P">
{else}
<INPUT type="hidden" name="usertype" value="{$usertype}">
{/if}
<INPUT type="hidden" name="redirect" value="{$redirect}">
{if $redirect ne "admin"}
<br>
<input type="checkbox" name="remember" value="Y">{$lng.lbl_remember_me}
{else}
<input type="hidden" name="remember" value="">
{/if}
<INPUT type="hidden" name="mode" value="login">
</TD>
</TR>
<TR>
<TD height="10" width="78" class="FormButton"></TD>
<TD width="10" height="10">&nbsp;</TD>
<TD width="282" height="10" class="ErrorMessage">
</TD>
</TR>
<TR>
<TD height="10" width="78" class="FormButton"></TD>
<TD width="10" height="10" class="FormButton">&nbsp;</TD>
<TD width="282" height="10">
{if $js_enabled}
{include file="buttons/submit.tpl" href="javascript:document.secureform.submit();" js_to_href="Y" onclick="confirmSubmit2()"}
{else}
{include file="submit_wo_js.tpl" value=$lng.lbl_submit}
{/if}
</TD>
</TR>
</FORM>
</TABLE>
<P>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_secure_login_form content=$smarty.capture.dialog extra="width=100%"}

and my secure_login.php code

#
# $Id: secure_login.php,v 1.1.2.4 2006/02/16 07:41:39 max Exp $
#

require "./auth.php";

if (!empty($HTTP_GET_VARS[$XCART_SESSION_NAME])) {
   if (empty($HTTP_COOKIE_VARS[$XCART_SESSION_NAME]))
      $HTTP_COOKIE_VARS[$XCART_SESSION_NAME] = $XCARTSESSID;
   func_header_location("secure_login.php");
}

require $xcart_dir."/include/categories.php";

$location[] = array(func_get_langvar_by_name("lbl_authentication"), "");

if($active_modules["Manufacturers"])
    include $xcart_dir."/modules/Manufacturers/customer_manufacturers.php";

#
# Assign Smarty variables and show template
#
$smarty->assign("main", "secure_login_form");

# Assign the current location line
$smarty->assign("location", $location);

func_display("customer/home.tpl",$smarty);
?>
« Last Edit: October 05, 2007, 12:05:41 PM by sparky672 » Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
Sparky
Moderator
Hero Member
*****

Karma: 85
Posts: 2,275


stop pushing all those buttons


View Profile
« Reply #9 on: October 05, 2007, 01:39:11 PM »

After logging in, do they get a confirmation page which displays their name/email?  If so, post that code here.
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
loneguard
Jr. Member
**

Karma: 0
Posts: 98


View Profile
« Reply #10 on: October 05, 2007, 04:01:14 PM »

OK, this is the welcome.tpl that I think is responsible for displaying their name after they successfully logged in:

{if ($active_modules.Greet_Visitor ne "") and ($smarty.cookies.GreetingCookie ne "") and $logout_user eq ''}
<H3>{$lng.lbl_welcome_back}, {$smarty.cookies.GreetingCookie|replace:"\'":"'"} </H3>
{else}
<H3>{$lng.lbl_welcome_to} { $config.Company.company_name }</H3>
{/if}
{$lng.txt_welcome}
<P>
{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"}
{include file="modules/Bestsellers/bestsellers.tpl"}
{/if}


$lng are language variables where labels, text vars, etc. are stored.

I know it's an uphill battle with me, but I AM doing the best I can Embarrassed
Logged
Sparky
Moderator
Hero Member
*****

Karma: 85
Posts: 2,275


stop pushing all those buttons


View Profile
« Reply #11 on: October 05, 2007, 04:39:23 PM »

I'm going to assume that, {$smarty.cookies.GreetingCookie|replace:"\'":"'"} is the macro that puts the customer's name on that page.  Let's put the email address issue aside for now.

As a test, put this Javascript on the Welcome page.  Put it in the <body> section but at the very END just before the </body> tag.

Quote
<script LANGUAGE="JavaScript"> <!--
var myname = {$smarty.cookies.GreetingCookie|replace:"\'":"'"};
document.cookie = "fullname="+myname+";path=/;";
// --></script>

This is mainly a test to see if you can generate a new cookie which contains the user's name.  It will generate the cookie after the Welcome page loads and the cookie will only be valid until you close the browser window.

1.  Login to the system to generate a Welcome page.  Look at the source code... find the new Javascript and see if the name has been inserted on the first line.  There might be issues with the quotes or lack of quotes.

2.  Then look at your browser's cookies for your domain.  Don't close the browser or the cookie will vanish.  See if you have a cookie named "fullname" and it contains the proper information.

If those tests are successful, I'll post some Javascript that you would put on your TTX newticket.html template that will read the cookie and insert into the name field automatically.  This second chunk is the easier part.
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
loneguard
Jr. Member
**

Karma: 0
Posts: 98


View Profile
« Reply #12 on: October 05, 2007, 04:52:16 PM »

Success! I made up a username "Arielle Kiebler" and logged in with her credentials.
Here's the snippet from the resulting page:

<script LANGUAGE="JavaScript"> <!--
var myname = Arielle Kiebler;
document.cookie = "fullname="+myname+";path=/;";
// --></script>
Logged
Sparky
Moderator
Hero Member
*****

Karma: 85
Posts: 2,275


stop pushing all those buttons


View Profile
« Reply #13 on: October 05, 2007, 04:58:10 PM »

Success! I made up a username "Arielle Kiebler" and logged in with her credentials.
Here's the snippet from the resulting page:

<script LANGUAGE="JavaScript"> <!--
var myname = Arielle Kiebler;
document.cookie = "fullname="+myname+";path=/;";
// --></script>

That's good.  But I'm concerned about the lack of quotes around the name itself (probably generated Javascript errors and failed to write a cookie).  Can you look for the cookie to see if the full name was stored properly?

If it failed:

try this...

var myname = '{$smarty.cookies.GreetingCookie|replace:"\'":"'"}';

or this...

var myname = "{$smarty.cookies.GreetingCookie|replace:"\'":"'"}";
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
loneguard
Jr. Member
**

Karma: 0
Posts: 98


View Profile
« Reply #14 on: October 05, 2007, 05:04:25 PM »

You know, the original cookie produces this:
<H3>Welcome back, Arielle Kiebler </H3>
That's the top of the home page 'View Source' output.
It's without quotes as well.
I'll try again with your modifications.
Logged
Pages: [1] 2 3 ... 5
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1 RC3 | SMF © 2001-2006, Lewis Media Valid XHTML 1.0! Valid CSS!
Page created in 0.03 seconds with 20 queries.