franknu Posted November 15, 2006 Share Posted November 15, 2006 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.phpwhen the user click on the link that match thier search[code=php:0]$bn = $row['BusinessName'];echo "<a href=\"bizwebpage2.php?BusinessName=$bn\">$bn</a>";[/code]then that link takes the user to another page call bizwebpage2.phpwhere i have some variables that i want to display that are on the same row as BusinessNamehere is the code for bizwebpage2.phpall the variables are define in page business_display and work finei was just wondering maybe i can use a $_session to carry the difine variables to bizwebpage.php page help please[code=php:0]<?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> </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> </td> </tr> </table> </td> </tr> </table> <?php ?> [/code]the error messager is Notice: Undefined index: BusinessName in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 20Notice: Undefined index: Keyword in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 21Notice: Undefined index: Picture1 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 22Notice: Undefined index: Headline in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 23Notice: Undefined index: Slogan2 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 24Notice: Undefined index: Description1 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 25Notice: Undefined index: Description2 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 26Notice: Undefined index: Description3 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 27Notice: Undefined index: Contact2 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 28Notice: Undefined index: Picture2 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 29Notice: Undefined index: Picture3 in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 30Notice: Undefined variable: Logo in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 51 Link to comment https://forums.phpfreaks.com/topic/27372-how-to-difine-variable-that-are-not-being-submitted/ Share on other sites More sharing options...
craygo Posted November 15, 2006 Share Posted November 15, 2006 Check to see if it isset[code]<?phpif(isset($_POST['BusinessName'])){$BusinessName = ($_POST['BusinessName']);} else {$BusinessName = "";}?>[/code]Looks to me like you only need BusinessName from the form and everything else is coming from the table. If I am correct it should look like this[code]<?php<?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()); if(isset($_GET['BusinessName'])){$BusinessName = ($_POST['BusinessName']);} else {die ("No Business name selected");}$query = "SELECT * FROM business_info WHERE `BusinessName`= '$BusinessName' "; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_assoc($result);$Keyword =($row['Keyword']); $Picture1 = ($row['Picture1']); $Headline = ($row['Headline']); $Slogan2 = ($row['Slogan2']); $Description1 =($row['Description1']); $Description2 = ($row['Description2']); $Description3= ($row['Description3']); $Contact2 = ($row['Contact2']); $Picture2 = ($row['Picture2']); $Picture3 = ($row['Picture3']); }?> <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> </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> </td> </tr> </table> </td> </tr> </table> <?php ?>[/code] Link to comment https://forums.phpfreaks.com/topic/27372-how-to-difine-variable-that-are-not-being-submitted/#findComment-125182 Share on other sites More sharing options...
franknu Posted November 15, 2006 Author Share Posted November 15, 2006 that seems to likes those code better, but i am getting:Notice: Undefined index: BusinessName in c:\program files\easyphp1-8\home\townsfinder\bizwebpage2.php on line 21 not more display after that also i am not posting any of this variables they are already in the page call busines_dispaly.php i just need those variables to go to the next page call bizwebpage2.php because i need to display the data in another Link to comment https://forums.phpfreaks.com/topic/27372-how-to-difine-variable-that-are-not-being-submitted/#findComment-125206 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.