Jump to content

a hack so beautiful


virtualadz

Recommended Posts

i found in my contact page, that anyone sending me message can press the submit button and then click on stop button in their browser and i stiil recieved email, i tried this 3 times and and all those 3 emails reached me. i want to disable the function so that once pressed it doesn't allow clicking once more. i found an example on dynamicdrive.com but it uses a submit button, and i have a image, i dont to replace it: <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>this is the image code, cani disable it for a image

Link to comment
Share on other sites

I guess you can use javascript to do that, I tried this disabled on an image, thought the appearence of image doesnt change like a button. seems to be working fine. just try this.<img src="image.JPG" onclick="java script:alert('hi');this.disabled=true;">when you click the image only 1st time the alert msg comes [just to test, shows the image is disabled] .

Link to comment
Share on other sites

where do i add this in php image code:<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>like this<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE, onclick="java script:alert('hi');this.disabled=true;"); ?></td>

Link to comment
Share on other sites

You can't add it to that code, that's a PHP function call to some template system or framework that you are using which generates the HTML code. You can either find and edit that function to update the HTML code it produces, which would apply to every place where that function gets called, or you can replace the function call and just put the HTML in there directly.

Link to comment
Share on other sites

this is my contact page

<?php/*  $Id: wholesale_inquiry.php,v 1.42 2003/06/12 12:17:07 hpdl Exp $*/  require('includes/application_top.php');  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_WHOLESALE);  $error = false;  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {    $name = tep_db_prepare_input($HTTP_POST_VARS['name']);    $email_address = tep_db_prepare_input($HTTP_POST_VARS['email']);    $enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);    if (tep_validate_email($email_address)) {      tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address);      tep_redirect(tep_href_link(FILENAME_WHOLESALE, 'action=success'));    } else {      $error = true;      $messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);    }  }  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_WHOLESALE));?><!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"><html <?php echo HTML_PARAMS; ?>><head><?php// BOF: Header Tag Controller v2.5.7if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {  require(DIR_WS_INCLUDES . 'header_tags.php');} else {?>   <title><?php echo TITLE; ?></title><?php}// EOF: Header Tag Controller v2.5.7?><base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"><link rel="stylesheet" type="text/css" href="stylesheet.css"><link rel="stylesheet" media="all" type="text/css" href="basic_dd.css" /><!--[if lte IE 6]><link rel="stylesheet" media="all" type="text/css" href="basic_dd_ie.css" /><![endif]--></head><body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"><!-- header //--><?php require(DIR_WS_INCLUDES . 'header.php'); ?><!-- header_eof //--><!-- body //--><table border="0" width="100%" cellspacing="3" cellpadding="3">  <tr>    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"><!-- left_navigation //--><?php require(DIR_WS_INCLUDES . 'column_left.php'); ?><!-- left_navigation_eof //-->    </table></td><!-- body_text //-->    <td width="100%" valign="top"><?php echo tep_draw_form('contact_us', tep_href_link(FILENAME_WHOLESALE, 'action=send')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">      <tr>        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">          <tr>            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_contact_us.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>          </tr>        </table></td>      </tr>      <tr>        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>      </tr><?php  if ($messageStack->size('contact') > 0) {?>      <tr>        <td><?php echo $messageStack->output('contact'); ?></td>      </tr>      <tr>        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>      </tr><?php  }  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) {?>      <tr>        <td class="main" align="center"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_man_on_board.gif', HEADING_TITLE, '0', '0', 'align="left"') . TEXT_SUCCESS; ?></td>      </tr>      <tr>        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>      </tr>      <tr>        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">          <tr class="infoBoxContents">            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">              <tr>                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>                <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>              </tr>            </table></td>          </tr>        </table></td>      </tr><?php  } else {?>      <tr>        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">          <tr class="infoBoxContents">            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">               <tr>                <td class="main"><?php echo ENTRY_NAME; ?></td>              </tr>              <tr>                <td class="main"><?php echo tep_draw_input_field('name'); ?></td>              </tr>              <tr>                <td class="main"><?php echo ENTRY_EMAIL; ?></td>              </tr>              <tr>                <td class="main"><?php echo tep_draw_input_field('email'); ?></td>              </tr>              <tr>                <td class="main"><?php echo ENTRY_ENQUIRY; ?></td>              </tr>              <tr>                <td>     <?php echo tep_draw_textarea_field('enquiry', 'soft', 50, 15, tep_sanitize_string($_POST['enquiry']), '', false); ?>      </td>             </tr>            </table></td>          </tr>        </table></td>      </tr>      <tr>        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>      </tr>      <tr>        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">          <tr class="infoBoxContents">            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">              <tr>                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>                <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>              </tr>            </table></td>          </tr>        </table></td>      </tr><?php  }?>    </table></form></td><!-- body_text_eof //-->      </tr></table><!-- body_eof //--><!-- footer //--><?php require(DIR_WS_INCLUDES . 'footer.php'); ?><!-- footer_eof //--><br></body></html><?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

That's good. Again, if you want to add a javascript event to the button, you can either edit the function that produces the button HTML and add it there, or replace the function call with the HTML for the button.

Link to comment
Share on other sites

as far as i can see these are 2 codes<td width="100%" valign="top"><?php echo tep_draw_form('contact_us', tep_href_link(FILENAME_WHOLESALE, 'action=send')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"><td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>i dont want to change the base fuctionality of the button. so in which code of the either should i place the js

Link to comment
Share on other sites

The javascript does not go in that code. That is a function call to a function named tep_image_submit. Presumably, the tep_image_submit function produces the HTML code for the button. I believe that tep_image_submit is a part of osCommerce. It might be possible to add another parameter to the function to put arbitrary attributes in the HTML, but I don't have the osCommerce documentation in front of me so I don't know if it is possible or not. Regardless, the point I'm trying to get across is that you have 2 options. You can either edit the tep_image_submit function to add the javascript to every button that it produces, or you can replace the call to tep_image_submit with the HTML code for the button itself. Those are your options.

Link to comment
Share on other sites

so now i get it, well, tep_image_submit is a core part of osc and i did rather stay away from that/ taking your solution, think i am left with only that, but since the tep_image_submit may be connected with security feature i am really afraid to use html there, really confused??

Link to comment
Share on other sites

ok i will look back at it after sometime. for now i think i should proceedwith my next question:i have my email box set to be filled, but the enquiry and name can be sent empty , is a way there to make it required "to enter at least 50 characters into the enquiry box, but not more than 400" i will come to name box later, this is the code i could come up to: here min is 50 how to set up max as 400 and also anything wrong in thise code

if( strlen($enquiry) < 50 ) {        $messageStack->add('contact_us', 'Please type some more text to send this form');        $error = true;}

and in the body

<?php  if ($messageStack->size('contact_us') > 0) {?>      <tr>        <td><?php echo $messageStack->output('contact_us'); ?></td>      </tr><?php  }?>

Link to comment
Share on other sites

Well, you typically don't want to give an error message like "either type more or less". You probably want to tell them exactly how many characters they have (or have some javascript counting it up as they type), and tell them what the minimum and maximum are so they aren't sitting there guessing. If you make it hard to use your site, people won't use it.If you want a single if statement, this is how you do it:if( strlen($enquiry) < 50 || strlen($enquiry) > 400 )

Link to comment
Share on other sites

well first i think i should ask you for a opinion, what would you prefer, throwing a js error just upon clicking the button, or bringing to the page again with the error printed. i will have two for now:1. Name reqd.2. Enquiry box minimum 50, max 500what do you think is it reqd. for the enqiry box to have both min and max (characters reqd.), or should i settle with one(either min or max). i will proceed after your answer!

Link to comment
Share on other sites

Javascript would be a better option here, you check the length right away and popup the error. If you reload, content of the page will be lost. he will have to type the content again. this might frustrate the user... And if you want to validate, doesnt matter if do 1 or both conditions. doesnt make a difference. I would suggest Javascript.

Link to comment
Share on other sites

hi there, i did want to add some more fields in my contact us page, this is what i have donein the body

<tr>                <td class="main"><?php echo tep_draw_input_field('type'); ?></td>              </tr>

now my question is where in this i add the fields in this code, so that the field is printed in the email $error = false; if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) { $name = tep_db_prepare_input($HTTP_POST_VARS['name']); $email_address = tep_db_prepare_input($HTTP_POST_VARS['email']); $enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']); if (tep_validate_email($email_address)) { tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address); tep_redirect(tep_href_link(FILENAME_WHOLESALE, 'action=success')); } else { $error = true; $messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR); } }

Link to comment
Share on other sites

ok i was able to add an extra field, but when i sent a message to my self, the data filled in that filed didn't appear n the email, what should i do, i need to add extra fields in my contact page, this is what i did, to add an extra field named "teatype"

$error = false;  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {    $name = tep_db_prepare_input($HTTP_POST_VARS['name']);    $email_address = tep_db_prepare_input($HTTP_POST_VARS['email']);    $enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);    [b]$teatype = tep_db_prepare_input($HTTP_POST_VARS['teatype']);[/b]    if (tep_validate_email($email_address)) {      tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address, [b]$teatype[/b]);

this is in the body part

  <tr>                <td class="main"><?php echo ENTRY_TEA_TYPE; ?></td>              </tr>              <tr>                <td class="main"><?php echo tep_draw_input_field('teatype'); ?></td>              </tr>

thanks for any help

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...