how to difine variable that are not being submitted

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
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

how to difine variable that are not being submitted

Post by franknu »

I need to define some variable that are not being sumited through a form,

I have a link which is on page call business_display.php

when the user click on the link that match thier search

Code: Select all

$bn = $row['BusinessName'];

echo "<a href=\"bizwebpage2.php?BusinessName=$bn\">$bn</a>";
then that link takes the user to another page call bizwebpage2.php

where i have some variables that i want to display that are on the same row as BusinessName

here is the code for bizwebpage2.php
all the variables are define in page business_display and work fine

i was just wondering maybe i can use a $_session to carry the difine variables to bizwebpage.php page help please

Code: Select all

<?php 

$host = "localhost"; 
$username = "localhost"; 
$password = "abc123"; 
$database = "contacts"; 


$db = mysql_connect($host, $username, $password) or die(mysql_error()); 
mysql_select_db($database) or die(mysql_error()); 

$BusinessName = ($_POST['BusinessName']); 
$Keyword =($_POST['Keyword']); 
$Picture1 =  ($_POST['Picture1']); 
$Headline = ($_POST['Headline']); 
$Slogan2 = ($_POST['Slogan2']); 
$Description1 =($_POST['Description1']); 
$Description2 = ($_POST['Description2']); 
$Description3= ($_POST['Description3']); 
$Contact2 =  ($_POST['Contact2']); 
$Picture2 = ($_POST['Picture2']); 
$Picture3 = ($_POST['Picture3']); 

if($BusinessName) 
{ 
$query = "SELECT * FROM business_info WHERE `BusinessName`= '$BusinessName' "; 
$result = mysql_query($query) or die (mysql_error()); 

}

?> 
<table> 
  <tr> 
    <td> 
      <table> 
        <tr> 
          <td valign="top"> 
            <table> 
              <tr> 
                <td valign="top"> 
                  <table> 
                    <tr>    
                      <td><?php echo"$Logo"; ?></td> 
                    </tr> 
                    <tr> 
                      <td valign="top"><h2><?php echo "<h2>$BusinessName</h2>"; ?></h2></td> 
                    </tr> 
                    <tr> 
                      <td valign="top"><?php echo "$Description1"; ?></td> 
                    </tr> 
                    <tr> 
                      <td valign="top"><?php echo "$Description2"; ?></td> 
                    </tr> 
                                        <tr> 
                      <td valign="top"><?php echo "$Description3"; ?></td> 
                    </tr> 
                    <tr> 
                      <td valign="top"><?php echo "$Contact2"; ?></td> 
                    </tr> 
                  </table> 
                </td> 
              </tr> 
            </table> 
          </td> 
          <td valign="top"> 
            <table> 
              <tr> 
                <td>&nbsp;</td> 
              </tr> 
              <tr> 
                <td valign="top"><?php echo"<img src='$Picture2' width='200' height='250'>"; ?> 
                                
                                </td> 
              </tr> 
              <tr> 
                <td valign="top"> <?php echo "<img src='$Picture3'  width='200' height='250'>"; ?>  </td> 
              </tr> 
            </table> 
          </td> 
        </tr> 
      </table> 
      <table border='1'> 
        <tr> 
          <td>&nbsp;</td> 
        </tr> 
      </table> 
    </td> 
  </tr> 
</table> 
<?php 

?>
the error messager is
Notice: Undefined index: BusinessName in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 20

Notice: Undefined index: Keyword in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 21

Notice: Undefined index: Picture1 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 22

Notice: Undefined index: Headline in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 23

Notice: Undefined index: Slogan2 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 24

Notice: Undefined index: Description1 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 25

Notice: Undefined index: Description2 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 26

Notice: Undefined index: Description3 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 27

Notice: Undefined index: Contact2 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 28

Notice: Undefined index: Picture2 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 29

Notice: Undefined index: Picture3 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 30

Notice: Undefined variable: Logo in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 51
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Use sessions, cookies, posting a form or sending by querystring ($_GET).
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post by franknu »

sound a little complicated can u guide me better please maybe some sample codes
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

franknu, you've had plenty of adjustment time to stop using aolspeak. Seriously now.

isset() should be of interest.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

franknu wrote:sound a little complicated can u guide me better please maybe some sample codes
try something 1st n post it. then we can help u wit ur code.

AND PLEASE STOP USING AOL SPEAK.
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post by franknu »

sorry, about the aol language. i guess i been spending to much time online lately
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Cool, just try to remember that there are a lot of people from a lot of different regions from around the world that might not be able to understand what you are saying when you speak that way.

/ scolding voice off

Now try putting some code out so we can look at what you are doing and try to help you with it.
Post Reply