X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Donate page (https://forum.x-cart.com/showthread.php?t=55212)

ARW VISIONS 08-23-2010 09:22 AM

Donate page
 
ver - 4.1.12

Ok so I have a donate page on a site I built.

Right now I just left the price blank so they can enter an amount in.

Is there a way to have a drop down with various amounts AND the empty text box as an other option?

cflsystems 08-23-2010 02:33 PM

Re: Donate page
 
You can. Just do a check after submit - if textbox empty use the amount from dropdown else use the amount from textbox. Also have to do check textbox allows numbers only. You have to do js client side check but also server side check in case js is turned off in customers browser

ARW VISIONS 08-23-2010 08:28 PM

Re: Donate page
 
ok I can do the JS part, but how do I do the server side part?

Shamun 08-23-2010 09:10 PM

Re: Donate page
 
Noob at PHP but perhaps something like this?

$var = intval($_POST['formName']);

ARW VISIONS 08-23-2010 09:11 PM

Re: Donate page
 
yeah, Im a design guy, so writing PHP to check that might be over my head. I'll check it out.

Shamun 08-23-2010 09:18 PM

Re: Donate page
 
Stupid forum submitted my post before I wanted.

What I posted before was simply making sure it was posted as an integar.
For checking which was submitted you could do maybe something like this:
Code:

$var = intval($_POST['formName']);
$var2 = intval($_POST['dropdownName']);

if($var > 0 && $var2 > 0) {
Both have stuff in them.  You decide which to use
}

if($var > 0) {
Value was found and is greater than 0  in the form.  Do php stuff
};

if($var2 > 0) {
Value was found and is greater than 0 in the dropdown.  Do php stuff
};



Again, I'm a noob at php and may be insecure or used too much logic/faulty logic.

cflsystems 08-24-2010 03:17 AM

Re: Donate page
 
Yes you need to do that in the php file responsible for processing the form. Something like
var1 -dropdown
var2 - text field

P.S. same happened to me - forum submitted before I finished

PHP Code:

if (!empty($var2)) {
 
# use text field value
 
if (!is_numeric($var2))
  
$error true;
  
# if field value is not a number throw an error, process it and redirect back to the form for re-submision
 
else
  
# if field value is a number
  
$var2 intval($var2);
 
# do more php stuff
} else {
 
# if text field is empty use dropdown value
 
$var1 intval($var1);
 
# do more php stuff




All times are GMT -8. The time now is 01:31 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.