2 problems in the following

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
ladydee
Forum Newbie
Posts: 4
Joined: Mon Mar 09, 2009 10:14 am

2 problems in the following

Post by ladydee »

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


I am trying to post to the user what they have selected and also trying to email to the user and the owner the category name.

Neither of these are working in the attached file.

Thank you for any help.
Ladydee

Code: Select all

 
<?php
ob_start();
session_start();
require_once("connect.inc");
 
?>
 
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Georgia Vending Services - Vending Services</title>
<link rel=stylesheet href=style.css type=text/css>
<style>
td{font-family:arial;font-size:12}
</style>
<link rel="stylesheet" href="image/style.css" type="text/css">
<link rel="stylesheet" href="image/linkstyle.css" type="text/css">
 
</head>
 
<body topmargin="0" leftmargin="0" background="image/background.gif">
<center>
 
<script>
function show_cart()
{
    window.open ('show_cart.php','','toolbars=0,scrollbars=0,width=300,height=300,top=100,left=160');
}
</script>
 
<p>
 
 
<?php
if ($_POST['B1'] == "Continue")
{
    $errorMessage = '';
    // first check if the number submitted is correct
    $number = $_POST['txtNumber'];
    //echo "number is=".$number."<br>";
    //echo md5($number)."<br>";
    //echo $_SESSION['image_random_value'];
    if (md5($number) == $_SESSION['image_random_value'])
    {
            //echo "iam in if"."<br>";
             // set the session
            $_SESSION['image_is_logged_in'] = true;
             // remove the random value from session 
             $_SESSION['image_random_value'] = '';
            // exit;
            //header("location:build_breakroom.php?value=Verified");
            //echo "<input type='hidden' value='verified' name='image_verify'>";
        
 
            //echo "iam in if";
            $categoryName=$GET["categoryName"];
            $category=$GET["cat_id"];
            $customername = $_POST["customer_name"];
            //echo "customer=".$customername."<br>";
            $companyname=$_POST["company_name"];
            //echo "companyname=".$companyname."<br>";
            $phone=$_POST["phone"];
            $address=$_POST["address"];
            $city=$_POST["city"];
            $newsletter=$_POST["newsletter"];
            $email=$_POST["email"];
            $no_emp=$_POST["no_emp"];
            $a1 = date(d,strtotime($_POST["reg_date"]));
            $b1 = date(m,strtotime($_POST["reg_date"]));
            $c1 = date(Y,strtotime($_POST["reg_date"]));
            
            $d1 = $c1 . "-" . $b1 . "-" . $a1;
 
            $reg_date=$d1;
            $flag=0;
 
    }
    else
    {
            //echo "iam in else"."<br>";
            $errorMessage = 'Sorry, wrong number. Please try again';
            header ("location:new_customer.php?error=$errorMessage");
    }
}
if ($newsletter) {
        //add record
        $sql = "insert into subscribers values('', '$_POST[email]', '$_POST[name]')";
        $result = mysql_query($sql,$conn) or die(mysql_error());
}
?>
 
<table width="46%" cellspacing cellpadding>
  <tr>
    <td width="100%"><img border="0" src="image/top.gif" width="780" height="10"></td>
  </tr>
  <tr>
    <td width="100%"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="780" height="66" title="header">
      <param name="movie" value="flash/header.swf">
      <param name="quality" value="high">
      <embed src="flash/header.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="780" height="66"></embed></object></td>
    
  </tr>
  <tr>
    <td width="100%"><center><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
 codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
 width="773" height="45" id="CC2440979" align="middle">
<param name="movie" value="mymenu.swf"/>
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="salign" value="lt" />
<param name="bgcolor" value="#ffffff" />
<embed src="mymenu.swf" quality="high" bgcolor="#ffffff" width="773" height="45"
 name="CoffeeCup" scale="noscale" salign="lt" align="middle" type="application/x-shockwave-flash"
 pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></center>
      </td>
  </tr>
  <tr>
    <td width="100%" height="16" bgcolor="#FFB600">&nbsp;</td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#FFB600">
      <table width="100%" cellspacing cellpadding>
        <tr>
          <td width="30%" valign="top" align="left"><br>
            <p>&nbsp;</p>
            <div align="center">
              <center>
              <table border="0" width="80%" cellspacing="5" cellpadding="0">
                <tr>
                  <td width="100%" class="MainTitle">Breakroom Selection</td>
                </tr>
                <tr>
<?
 
$category = $_POST["category"];
 
if(strlen($category)>0)
{
        foreach ($_POST['category'] as  $category) 
        { 
if ($category == "1")
            {
                $_SESSION['snack'] = "";
            }
            if ($category == "2")
            {
            $_SESSION['colddrink'] = "";
            }
            if ($category == "3")
            {
            $_SESSION['frozen'] = "";
            }
            if ($category == "4")
            {
            $_SESSION['hotbeverage'] = "";
            }
            if ($category == "5")
            {
            $_SESSION['watercooler'] = "";
            }
            if ($category == "6")
            {
            $_SESSION['bsupplies'] = "";
            }
 
        }
$category = $_POST["category"];
 
}
 
if ($_SESSION['ss_cust_id'] != "")
{
    $sql = "SELECT tblcustcat.category_id,categoryName FROM tblcustcat,tblcategory where tblcustcat.category_id=tblcategory.category_id and cust_id=".$_SESSION['ss_cust_id'];
    $result = mysql_query($sql);
    $noofrow = mysql_num_rows($result);
    }
 
$cnt = 0;
    if ($_SESSION['snacktype'] != "")
    {
     
     $cnt = $cnt + 1;
    }
    if ($_SESSION['drinktype'] != "")
    {
        $cnt = $cnt + 1;    }
    if ($_SESSION['coffeetype'] != "")
    {
        $cnt = $cnt + 1;    }
    if ($_SESSION['foodtype'] != "")
    {
        $cnt = $cnt + 1;    }
    if ($_SESSION['water_coolertype'] != "")
    {
        $cnt = $cnt + 1;    }
    if ($_SESSION['suppliestype'] != "")
    {
        $cnt = $cnt + 1;    }
 
 
    ?>
 
                  <td width="100%" class="GeneralText"><span style="mso-bidi-font-size: 10.0pt; mso-fareast-font-family: Times New Roman; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><? if ($cnt != 0) { echo " $cnt Items Selected "; }?></span>
                    <p></td>
                </tr>
                <tr>
                  <td width="100%"><?php
?>
<form method=post action=new_cust_final.php>
<?
if ($_SESSION['ss_cust_id'] != "")
{
echo "<table border=0 cellpadding=5 cellspacing=5 bordercolor=maroon width=90%>";
if ($_SESSION['snack'] != "")
{
$query = "select * from tblcategory where category_id=".$_SESSION['snack'];
$result = mysql_query($query);
$no = mysql_num_rows($result);
$array = mysql_fetch_object($result);
if ($no > 0)
{
        echo "<tr><Td width=10><input type=checkbox name=category[] value=".$_SESSION['snack']."></td><td class=GeneralText>".$array->categoryName."</td></tr>";
        
}
}
if ($_SESSION['colddrink'] != "")
{
$query = "select * from tblcategory where category_id=".$_SESSION['colddrink'];
$result = mysql_query($query);
$no = mysql_num_rows($result);
$array = mysql_fetch_object($result);
if ($no > 0)
{
        echo "<tr><Td width=10><input type=checkbox name=category[] value=".$_SESSION['colddrink']."></td><td class=GeneralText>".$array->categoryName."</td></tr>";
}
}
if ($_SESSION['frozen'] != "")
{
$query = "select * from tblcategory where category_id=".$_SESSION['frozen'];
$result = mysql_query($query);
$no = mysql_num_rows($result);
$array = mysql_fetch_object($result);
if ($no > 0)
{
        echo "<tr><Td width=10><input type=checkbox name=category[] value=".$_SESSION['frozen']."></td><td class=GeneralText>".$array->categoryName."</td></tr>";
}
 
}
if ($_SESSION['hotbeverage'] != "")
{
$query = "select * from tblcategory where category_id=".$_SESSION['hotbeverage'];
$result = mysql_query($query);
$no = mysql_num_rows($result);
$array = mysql_fetch_object($result);
if ($no > 0)
{
        echo "<tr><Td width=10><input type=checkbox name=category[] value=".$_SESSION['hotbeverage']."></td><td class=GeneralText>".$array->categoryName."</td></tr>";
}
 
}
if ($_SESSION['bsupplies'] != "")
{
$query = "select * from tblcategory where category_id=".$_SESSION['bsupplies'];
 
$result = mysql_query($query);
$no = mysql_num_rows($result);
$array = mysql_fetch_object($result);
if ($no > 0)
{
        echo "<tr><Td width=10><input type=checkbox name=category[] value=".$_SESSION['bsupplies']."></td><td class=GeneralText>".$array->categoryName."</td></tr>";
}
 
}
 
if ($_SESSION['watercooler'] != "")
{
$query = "select * from tblcategory where category_id=".$_SESSION['watercooler'];
$result = mysql_query($query);
$no = mysql_num_rows($result);
$array = mysql_fetch_object($result);
if ($no > 0)
{
        echo "<tr><Td width=10><input type=checkbox name=category[] value=".$_SESSION['watercooler']."></td><td class=GeneralText>".$array->categoryName."</td></tr>";
}
 
}
        ?>
              </center>
        <Tr><Td colspan=2 align=center>
        <p align="left">
<?
        if ($_SESSION['snack'] == "" && $_SESSION['colddrink'] == "" && $_SESSION['frozen'] == "" && $_SESSION['hotbeverage'] == "" && $_SESSION['watercooler'] == "")
        {
        }
        else
        {
?>
        <input type=submit value=Remove class=button1>
<?
}
?>      
        </p>
        
        </td></tr></table>
 
              <center>
    <?
    }
    ?></center></td>
                </tr>
                <tr>
                  <td width="100%"><br>
<?                      if ($_SESSION['snack'] == "" && $_SESSION['colddrink'] == "" && $_SESSION['bsupplies'] == "" && $_SESSION['frozen'] == "" && $_SESSION['hotbeverage'] == "" && $_SESSION['watercooler'] == "")
        {
        }
        else
        
        { ?>
 
                  <input type="submit" value="Finish / Submit" name="B1" class="button3"><? } ?></td>
<?
    
$categoryName=$GET["categoryName"];
$subject = "Request For Vending Services Category Name: " . $_POST['category_id'];
//$subject = "Request For Vending Services";
                    
                    $msg = "Customer Name: $_POST[customer_name]\n";
                    $msg .= "Company Name: $_POST[company_name]\n";
                    $msg .= "Phone: $_POST[phone]\n";
                    $msg .= "Address: $_POST[address]\n";
                    $msg .= "City: $_POST[city]\n";
                    $msg .= "No. of Employees: = $_POST[no_emp]\n";
                    $msg .= "E-Mail:  $_POST[email]\n";
                    $msg .= "Category Name: $_POST[categoryName]\n";
                    
                    //Mail to Client
                    
                        $mailheaders = "From: info@georgiavendingservices.com\n";
                        $mailheaders .= "$_POST[email]"."\r\n";
                        $mailheaders .= "Bcc: deemurphy_us@yahoo.com"."\r\n";
                        $headers .= "Bcc: your@domainname.com"."\r\n";
                    //  $mailheaders .= "Bcc: rsmith_gvs@bellsouth.net"."\r\n";
                        $mailheaders .= "MIME-Version: 1.0\n";
                        $mailheaders .= "Content-type: text/html; charset=iso-8859-1\n";
                        $mailheaders .= "X-Priority: 1\n";
                        $mailheaders .= "X-MSMail-Priority: High\n";
                        $mailheaders .= "X-Mailer: php\n";
                        $To .= "$_POST[email]";
                        mail($To,$subject,$msg,$mailheaders);
?>
                  
                </tr>
                <tr>
                  <td width="100%"></td>
                </tr>
              </table>
            </div>
          </td>
          <td width="70%" valign="top" align="left">
                    <?   if($flag==1)
                    {
                    echo "<center><Br><br><Br>";
                    echo $err_msg;
                    echo "<Br>";
                    echo "<input type=button onClick='javascript&#058;history.back();' value='Try Again' class=button2>";
                    ?>
                    <table border="0" width="100%" bgcolor="#FFB600">
                      <tr>
                        <td width="100%" height="175">&nbsp;</td>
                      </tr>
                    </table>
                    <?
                    }
                    else
                    {
                    ?>
   
            <p style="margin-left: 10" class="MainTitle">Build Your Breakroom</p>
            <p style="margin-left: 10" class="GeneralText"><span style="mso-bidi-font-size: 10.0pt; mso-fareast-font-family: Times New Roman; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">Please
                                select an item on the below to add machines /
                                services to your Breakroom</span></p>
            <div align="center">
              <center>
              <table border="0" width="90%" cellspacing="10" cellpadding="0">
                <tr>
                  <td width="30%" align="center" valign="bottom"><a href="snack.php"></a><a href="snack.php"><img border="0" src="image/buttons/snacks_img.jpg" width="75" height="98"></a><br>
                    <a href="snacktype.php" class="MainTitle">Snacks</a></td>
                  <td width="30%" align="center"  valign="bottom"><a href="drinktype.php"><img border="0" src="image/buttons/colddrink_img.jpg" width="75" height="96"></a><br>
                    <a href="drinktype.php" class="MainTitle">Cold Drinks</a></td>
                  <td width="30%" align="center" valign="bottom"><a href="foodtype.php"><img border="0" src="image/buttons/food_img.jpg" width="75" height="98"></a><br>
                    <a class="MainTitle" href="foodtype.php">Frozen / Cold Food</a></td>
                </tr>
                <tr>
                  <td width="30%" align="center"  valign="bottom">&nbsp;
                    <p><a href="coffeetype.php"><img border="0" src="image/buttons/coffee_img.jpg" width="77" height="84"></a><br>
                    <a class="MainTitle" href="coffeetype.php">Hot Beverage / Office Coffee</a></p>
                  </td>
                  <td width="30%" align="center"  valign="bottom"><a href="water_coolertype.php"><img border="0" src="image/buttons/watercooler_img.jpg" width="75" height="78"></a><br>
                    <a class="MainTitle" href="water_coolertype.php">Filter Water Coolers</a></td>
                  <td width="30%" align="center"  valign="bottom"><a href="suppliestype.php"><img border="0" src="image/buttons/supplies_img.jpg" width="75" height="86"></a><br>
                    <a class="MainTitle" href="suppliestype.php">Breakroom Supplies</a></td>
 
                </tr>
              </table>
              <input type="submit" value="Finish / Submit" name="B1" class="button3">
              </center>
            </div>
            <p style="margin-left: 45; margin-right: 25" align="justify">
            <p style="margin-left: 45; margin-right: 25" align="justify">&nbsp;<? } ?></center></td>
 
        </tr>
      </table>
    </td>
    
  </tr>
  
  <tr>
    <td width="100%"><img border="0" src="image/white.gif" width="780" height="1"></td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#EC4C11" height="25">
      <p align="center"><font face="Arial" size="2" color="#FFFFFF">Copyright @
      2009 Georgia Vending
      Services&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      Privacy Statement</font></td>
  </tr>
  <td width="100%">
    <p align="center"><font face="Arial" size="2"><b><a href="index.php"><font color="#FFFFFF">Home</font></a> 
      | <a href="about.html"><font color="#FFFFFF">About Us</font></a>  | <a href="community_services.html"><font color="#FFFFFF">Community Services</font></a> | <a href="emp_opp.php"><font color="#FFFFFF">Employment Opportunities</font></a> | <a href="contact.html"><font color="#FFFFFF">Contact Us</font></a> | <a href="new_customer.php"><font color="#FFFFFF">New Customer</font></a> | <a href="vending_services.html"><font color="#FFFFFF">Vending Services</font></a> <br> <a href="office_coffee.html"><font color="#FFFFFF">Office Coffee</font></a> | <a href="Whatsnew.php"><font color="#FFFFFF">Whats New</font></a>  |  <a href="manage.php"><font color="#FFFFFF">Newsletter</font></a></font></p>
    </td>    
</table>
 
        <?
            mysql_close($conn);
        ?>
                </form>
</body>
</center>
</html>

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
Last edited by ladydee on Mon Mar 09, 2009 11:27 am, edited 1 time in total.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: 2 problems in the following

Post by papa »

Some code might be helpful.
ladydee
Forum Newbie
Posts: 4
Joined: Mon Mar 09, 2009 10:14 am

Re: 2 problems in the following

Post by ladydee »

Can I get some help with these problems?

Thank you
LadyDee
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: 2 problems in the following

Post by pickle »

To be honest, it's not likely you'll get any help - for a couple reasons.

1) You've just said you have a problem and could we please fix it? There's no indication of what you've tried to do, or any evidence of narrowing down the problem on your part
2) That's a ton of code for someone to go through, looking for absolutely anything that could cause a problem.

Try to be more specific - as in which particular part you think is causing the problem, what you've tried so far, what exactly you expect to happen and what exactly is happening.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
ladydee
Forum Newbie
Posts: 4
Joined: Mon Mar 09, 2009 10:14 am

Re: 2 problems in the following

Post by ladydee »

I am trying to insert name into the subscriber table of the database. Email get inserted, but not name and when I echo name it gets I get the correct return. There are several tables and some use customerName and others use name. I have alot of code already written that used both, but this is failing for some reason.

Thank you
LadyDee
Post Reply