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

Radio buttons in email form

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-15-2005, 11:10 AM
  JJH1947's Avatar 
JJH1947 JJH1947 is offline
 

Advanced Member
  
Join Date: Feb 2004
Location: Whitefish, Montana
Posts: 41
 

Default Radio buttons in email form

On our web site's Product Detail pages I have added an "Ask an Expert" button. See, for example http://www.bitsbytescomputer.com/store/customer/product.php?productid=95&cat=24&page=1

Clicking this button pops up a simple email form (see code below). One line in this form looks like this "Preferred Contact Method: o Email o Phone," where the two "o"s are radio buttons. The idea is that the value of the radio button would be passed to the email that is sent to our Customer Service so we would know whether the customer wants to receive our advice via email or via phone. The form is working (the emails come through, along with all the customer-inserted information), and we have made some sales through this mechanism. However, the value of the radio buttons is not being passed to the emails. I have inserted the tpl code and the related php code below.

Any help that anyone can provide to help me get the values of the radio buttons passed to the emails would be most appreciated.

(1) customer/main/email_to_expert.tpl --> code for the email form
Code:
{ config_load file="$skin_config" } <html> <head> <title>{$lng.txt_site_title}</title> { include file="meta.tpl" } <link rel="stylesheet" href="{$SkinDir}/customer/style_customer.css"> </head> <body LEFTMARGIN=0 TOPMARGIN=0 RIGHTMARGIN=0 BOTTOMMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0> {if $mode eq "send"} <center><div class="errordata02">Your message has been sent.</div> [img]{$ImagesDir}/bitsbytes_03_2004/closewindow.gif[/img] </center> {else} <TABLE border=0 width=600px align=center><TR><TD style="padding-top:12px;padding-left:6px" width=100% class=errordata02 align=center>Ask An Expert About:</TD> <TD><span class="normaljump">CloseWindow</span></TD> </TR></TABLE> {capture name=dialog_04} <table border=0 width=600px> <tr> <td valign=top align=left width=100 style="padding-left:12px; padding-top:0px"> {include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url} </td> <TD class=errordata03 align="left" width="100%" style="padding-left:12px">Please let us know how we can help you. If our experts cannot answer your question, we will do our best to put you in touch with someone who can. Thank you for your interest in our products. <TABLE border=0 width=500px> <TR> <TD align=left width="20%"><div valign="absmiddle"><nobr>[img]{$ImagesDir}/bitsbytes_03_2004/bits_bytes_logo.gif[/img] </TD> <TD class="space" width="80%" align=left style="padding-top:12px">Experienced Guides.Trustworthy Tools.&trade;</nobr> </TD> </TR> </TABLE> </td> </TR> </table> {/capture} {assign var=without_tags value=$product.product} {assign var=with_tags value="<div class=errordata02u align=center>$without_tags</div>"} {eval var=$with_tags assign=prod_title} {* jjh jjh *} {include file="customer/dialog_03a.tpl" title=$prod_title content=$smarty.capture.dialog_04 extra="width=100%"} {capture name=dialog_04} <table border=0 width=500px align=center> <form name=sendform method=post action="email_to_expert.php?mode=send"> <input type=hidden name=productid value="{$product.productid}"> <div align=center><font color=red>{$error}</font></div> <TR> <td align=right width="10%" class="space"><nobr>Name:</nobr> <font class=Star>*</font></td> <td align=left width="90%"><input type=text name="your_name" value="{$your_name}" style="width: 200px;"> </td> </tr> <TR> <td align=right width="10%" class="space"><nobr>Email:</nobr> <font class=Star>*</font></td> <td align=left width="90%"><input type=text name="your_email" value="{$your_email}" style="width: 200px;"> </td> </tr> <tr> <td align=right width="10%" class="space"><nobr>Contact Phone:</nobr> </td> <td align=left width="90%"><input type=text name="phone" value="{$phone}" style="width: 200px;"> (optional) </td> </tr> <TR><TD align=right width="10%" class="space"><nobr>Preferred Contact Method: </TD> <TD align=left width="90%"> {*<input type="radio" name="contact" value="{$email_me}" checked> Email <input type="radio" name="contact" value="{$phone_me}"> Phone *} <input type="radio" name="contact" value="E-mail" checked> Email <input type="radio" name="contact" value="Phone-me"> Phone </nobr> </TD> </TR> <tr> <td align=right {*width=50%*} class="space">Message: </td> <td align=left {*width=50%*} style="padding-right:6px"><textarea name="message" cols=50 rows=5>{$message}</textarea> </td> </tr> <input type=hidden name="friend_email" value="{$friend_email}"> <tr> <td>[img]{$ImagesDir}/spacer.gif[/img] </td> <TD> <TABLE width=100%> <TR> <TD align=left><span class="normaljump">Click to see Privacy Notice</span> </TD> <TD align=right>[img]{$ImagesDir}/bitsbytes_03_2004/send.gif[/img] </TD> </TR> </TABLE> </TD> </tr> </form> </table> {/capture} {include file="customer/dialog_04.tpl" title="" content=$smarty.capture.dialog_04 extra="width=100%"} {/if} </body> </html>

(2) mail/send_to_expert.tpl --> code for the email itself
Code:
{* $Id: send_to_expert.tpl,v 1.1 2005/08/15 18:22:03 jjh $ *} {config_load file="$skin_config"} {include file="mail/html/mail_header.tpl"} <div class="space">[img]http://www.bitsbytescomputer.com/store/assets/bitsbytes_03_2004/images/bitsbytes_03_2004/bits_bytes_logo.gif[/img]</div> [img]http://www.bitsbytescomputer.com/store/assets/bitsbytes_03_2004/images/bitsbytes_03_2004/tagline_02.gif[/img] <DIV class="email"> {$lng.lbl_hello} {$lng.eml_your_name}: {$your_name} {$lng.eml_email}: {$email} {$lng.eml_phone}: {$phone} {$lng.eml_prefer_contact}: {if "E-mail"} "AAA" {else} "BBB" {/if} {$email} {$lng.eml_has_asked} {$lng.eml_message}: {$message} <font color=#AA0000>{$product.product}</font> {$lng.eml_please_click_link}: {$http_location}/customer/product.php?productid={$product.productid} </p> {include file="mail/html/signature_email.tpl"} </DIV>

(3) email_to_expert.php --> php code that sends email

Code:
<?php /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2004 Ruslan R. Fazliev <rrf@rrf.ru> | | All rights reserved. | +-----------------------------------------------------------------------------+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" | | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE | | AT THE FOLLOWING URL: http://www.x-cart.com/license.php | | | | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE | | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. | | FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING | | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). | | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT | | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, | | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY | | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS | | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS | | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND | | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS | | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE | | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.| | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. | | | | The Initial Developer of the Original Code is Ruslan R. Fazliev | | Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2004 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: product.php,v 1.55.2.1 2004/02/05 12:25:45 mclap Exp $ # require "./auth.php"; # # Put all product info into $product array # $email=array_pop(func_query_first("select email from $sql_tbl[customers] where login='$login'")); $smarty->assign("your_email",$email); $smarty->assign ("your_name", $your_name); if($mode=="send") { if(empty($your_email) || empty($your_name)){ /* if(empty($friend_email) || empty($your_email)){ */ $smarty->assign("error", "Sorry, the form was not filled in correctly."); $smarty->assign ("your_email", $your_email); /* $smarty->assign ("friend_email", $friend_email); */ $smarty->assign ("friend_email", "expert@bitsbytescomputer.com"); $smarty->assign ("message", $message); $smarty->assign ("phone", $phone); $smarty->assign ("your_name", $your_name); $smarty->assign ("email_me", $email_me); $smarty->assign ("phone_me", $phone_me); } else { $check=array_pop(func_query_first("select do_not_email from $sql_tbl[customers] where email='$friend_email'")); if($check=="Y"){ $smarty->assign("error", "This customer does not want to receive mail."); $smarty->assign ("your_email", $your_email); /* $smarty->assign ("friend_email", $friend_email); */ $smarty->assign ("friend_email", "expert@bitsbytescomputer.com"); $smarty->assign ("message", $message); $smarty->assign ("phone", $phone); $smarty->assign ("your_name", $your_name); $smarty->assign ("email_me", $email_me); $smarty->assign ("phone_me", $phone_me); } else { $product = func_select_product($productid, $user_account['membership']); $mail_smarty->assign ("product", $product); $mail_smarty->assign ("email", $your_email); $mail_smarty->assign ("message", $message); $mail_smarty->assign ("phone", $phone); $mail_smarty->assign ("your_name", $your_name); $mail_smarty->assign ("email_me", $email_me); $mail_smarty->assign ("phone_me", $phone_me); func_send_mail ("expert@bitsbytescomputer.com","mail/send_to_expert_subj.tpl","mail/send_to_expert.tpl",$your_email, false); /* func_send_mail ($friend_email, "mail/send_to_expert.tpl", "mail/wishlist_send2friend_subj.tpl", "mail/send_to_friend.tpl", $your_email, false); */ /* func_send_mail ("expert@bitsbytescomputer.com", "mail/wishlist_send2friend_subj.tpl", "mail/send_to_friend.tpl", $your_email, false); */ $smarty->assign("mode", "send"); } } } $product_info = func_select_product($productid, @$user_account['membership']); $smarty->assign("product",$product_info); $smarty->display("customer/main/email_to_expert.tpl"); ?>
__________________
X-Cart v. 3.5.4 [Linux]
PHP 4.3.9
MySQL 4.1.12
Perl 5.008005
Apache/2.0.52 [CentOS]

http://www.bitsbytescomputer.com
\"Trustworthy tools for biblical studies.\"
Reply With Quote
  #2  
Old 10-16-2005, 07:08 PM
  JJH1947's Avatar 
JJH1947 JJH1947 is offline
 

Advanced Member
  
Join Date: Feb 2004
Location: Whitefish, Montana
Posts: 41
 

Default

Here is a simplified version of my question:

How should I modify or rewrite this code in one template:

Code:
<input type="radio" name="contact" value="email_me"{if $contact ne "phone_me"}checked{/if}> Email <input type="radio" name="contact" value="phone_me"{if $contact eq "phone_me"}checked{/if}> Phone

so that the selected value is passed to this line in an email template:

Code:
{$lng.eml_prefer_contact}: {$contact}

and what code for "contact" should appear in the php file that actually processes the email?

Thanks for any help anyone!

John
__________________
X-Cart v. 3.5.4 [Linux]
PHP 4.3.9
MySQL 4.1.12
Perl 5.008005
Apache/2.0.52 [CentOS]

http://www.bitsbytescomputer.com
\"Trustworthy tools for biblical studies.\"
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 01:11 AM.

   

 
X-Cart forums © 2001-2020