Problem using isset

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

Post Reply
thrdnttkn
Forum Newbie
Posts: 2
Joined: Tue May 11, 2004 1:45 pm

Problem using isset

Post by thrdnttkn »

I would like some help on an ecommerce site I'm working on. List below are the HTML code and PHP code I'm dealing with. There are two buttons: Buy Now and Finance, which should go to different places (see PHP code) when the user clicks on them. However, currently, both are going to the "else" place in financing.phtm. I should say at the outset that this code worked on another website (I took over from a previous web developer) this company uses (both HTML and PHP). I'm lost. An FYI question, do the isset variables get set anywhere other than in the PHP file? Thanks in advance for any help.

HTML:

Code: Select all

<form action="financing.phtml" method="post">
<input type="hidden" name=productї] value="Big Stuff">
<input type="hidden" name=price value= "195.00">
<input type="hidden" name=units value="0">
                        <table border="2" cellpadding="5"
                        cellspacing="0" style=
                        "border-collapse: collapse">
                          <tr>
                            <td>
                              <font face="Trebuchet MS">
                               </font> <b>Big Stuff<br />
                              <font size="2">Retail
                              <strike>$230.00</strike><br />
                              Wholesale $202.00<br /></font>
                              <font size="2" color="#FF0000">Sale
                              Price * $195.00</font><br />
                              <font face="Trebuchet MS">
                              <select size="1" name="productї]1">
                                                                <input type=image src="images/buynow.jpg" value="Buy Now" alt="Buy Now" width="80" height="24">
                                <font face="Trebuchet MS">
                                
                                <br />
                                <font color="#336600" size=
                                "2">Standard Package</font><font color="#336600">
								</font> 
								</b>
                              </center>
                              </td>

                            <td bgcolor="#CCFFCC">
                            <b><font size="2">
                            $97.83/mo.</font></b><br />
                            <input type="image" value="Finance"
                            src="images/finance.jpg" alt="Finance"
                            width="80" height="24"><br />
                            <font size=
                            "2"><b>48 </b></font><b><font size=
                            "2">months</font></b> </td>
                          </tr>
                        </table>
                      </form>
PHP (financing.phtml):

Code: Select all

if (isset($BuyNow_x) || ($submit == "Buy Now") || isset($BuyNow))
{
  if (is_array($product))
    $product = implode(", ", $product);
  header("Location: http://ww7.aitsafe.com/cf/add.cfm?useri ... its=$units");
  exit;
}
else
{
  if (is_array($product))
    $product = implode(", ", $product);
  header("Location: https://www.securewebexchange.com/diamo ... ice=$price");
  exit;
}
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Added

Code: Select all

-tags for readability.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

a form field name of "product[]1" seems a bit screwy. Additionally, the select field is never closed. Neither of the buttons have names associated with them. So I don't know exactly how php with register_globals on will handle that. I'd suggest turning off register_globals and giving both buttons names which you can then search for.

second, it may be a good idea to urlencode() $product before passing it into that redirect.
Post Reply