discount voucher how to set up using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: discount voucher how to set up using php

Post by jonnyfortis »

Does it work with the very first code in the table? Because with
no nothing is showing when the form is submitted.

in the DB table i have two columns
VID tinyint(4) auto_increment
VCode varchar(20)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: discount voucher how to set up using php

Post by Christopher »

Do you know what is in $_POST['vouchCode'] and $row_rsVoucher['VCode'] ?
(#10850)
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: discount voucher how to set up using php

Post by jonnyfortis »

Do you know what is in $_POST['vouchCode'] and $row_rsVoucher['VCode'] ?
i only have one record added at the moment

VID 1
VCode lot123£10
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: discount voucher how to set up using php

Post by Christopher »

jonnyfortis wrote: i only have one record added at the moment

VID 1
VCode lot123£10
So that's what is in the database. Buhe what are the values of $_POST['vouchCode'] and $row_rsVoucher['VCode'] ? Is the value above loaded? What is passed in the form field?
(#10850)
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: discount voucher how to set up using php

Post by jonnyfortis »

So that's what is in the database. Buhe what are the values of $_POST['vouchCode'] and $row_rsVoucher['VCode'] ? Is the value above loaded? What is passed in the form field?
so i should try and echo them out?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: discount voucher how to set up using php

Post by Christopher »

That is one way to see the values. Try it! ;)
(#10850)
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: discount voucher how to set up using php

Post by jonnyfortis »

i added the following to the shopping cart

Code: Select all

            <?php echo $_POST['vouchCode']; ?><br />
           <?php echo $row_rsVoucher['VCode']; ?> <br />
and before i have hit submit i get the following results

Code: Select all

lot123�10 
then if i add the only discount value i have at the moment

lot123£10 to the form and submit it i get the following results

lot123£10
lot123�10
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: discount voucher how to set up using php

Post by Christopher »

So those don't look the same. What is that character in the database between "lot123" and "10" ?
(#10850)
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: discount voucher how to set up using php

Post by jonnyfortis »

Code: Select all

So those don't look the same. What is that character in the database between "lot123" and "10" ?
i dont know thats not what is stored in the DB...it must be an encoding issue?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: discount voucher how to set up using php

Post by Christopher »

Well ... the values in the database need to be able to match the values that can be entered in the form. How do you enter the voucher codes into the database?
(#10850)
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: discount voucher how to set up using php

Post by jonnyfortis »

Christopher wrote:Well ... the values in the database need to be able to match the values that can be entered in the form. How do you enter the voucher codes into the database?
via a form in the backend of the website but they go into the DB correctly
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: discount voucher how to set up using php

Post by Christopher »

Looks like either your database table/field is not UTF8 (try utf8_general_ci) or maybe the sprintf() or some other function is causing the problem. Maybe try concatenating instead of sprintf().
(#10850)
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: discount voucher how to set up using php

Post by jonnyfortis »

i tried changing UTF8 to charset= "utf8_general_ci" as suggested but am now getting errors

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1) in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 4

Warning: Cannot modify header information - headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1) in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 5

Warning: Cannot modify header information - headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1) in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 6

Warning: Cannot modify header information - headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1) in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 7

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1) in /homepages/6/d330188495/htdocs/beta/XCInc/XCart.inc on line 4
and these lines of code are

Code: Select all

header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    	        // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate");  	        // HTTP/1.1
header ("Pragma: no-cache");   
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: discount voucher how to set up using php

Post by Christopher »

jonnyfortis wrote:i tried changing UTF8 to charset= "utf8_general_ci" as suggested but am now getting errors
You changed the character coding in your database table? Or for your HTML document?
jonnyfortis wrote:

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1) in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 4

...

[syntax=php]header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    	        // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate");  	        // HTTP/1.1
header ("Pragma: no-cache");   
It says the there is output before line 4 in that file. So what is before the first header() call you list above (if that is line 4)?
(#10850)
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: discount voucher how to set up using php

Post by jonnyfortis »

Christopher wrote:
jonnyfortis wrote:i tried changing UTF8 to charset= "utf8_general_ci" as suggested but am now getting errors
You changed the character coding in your database table? Or for your HTML document?
jonnyfortis wrote:

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1) in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 4

...

[syntax=php]header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    	        // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate");  	        // HTTP/1.1
header ("Pragma: no-cache");   
It says the there is output before line 4 in that file. So what is before the first header() call you list above (if that is line 4)?
i changed the html document

the only code above this is

Code: Select all

<?php require_once('Connections/lotties.php'); ?>
<?php
// do not cache
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    	        // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate");  	        // HTTP/1.1
header ("Pragma: no-cache");    
Post Reply