Jump to content

Recommended Posts

Ok, I am very confuse on this one,

 

I have a page where users can send a message into the database which eventually the business can log in and  he/she can see, his/her messages. that had been posted to his business,

 

i am doing it with a session which,  i will call later to display the messages sent to that business

 

my problem is that the $_SESSION['BusinessName']; is not bein taken to page2. I did some testing and it takes other values to page2 but not BusinessName value

 

here is my code for page1 please help

 


<?php 
session_start(); 
$_SESSION['BusinessName'] ='$BusinessName'; 
$_SESSION['test']='test 1'; // this is the test line

?> 


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

if(isset($_GET['BusinessName'])){ 


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

$BusinessName= ($row['BusinessName']); 
$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']); 
$Business_Address=($row['Business_Address']); 
$make=($row['make']); 
$type=($row['type']); 
$Tel=($row['Tel']); 
$Website=($row['Website']); 
} 
?> 


<center>

<?php 

$_SESSION['BusinessName']; 
?> 

<pre>_SESSION:<?php print_r($_SESSION); ?></pre>


<table width="200" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td valign="top">
<?php include("includefiles/banner.php"); ?>
<table width="778" border="0" cellpadding="0" cellspacing="0">
      <tr>



this <pre>_SESSION:<?php print_r($_SESSION); ?></pre>

on page1 display _SESSION:Array
(
    [businessName] => NEW ENGLAND SEAFOODS
    [test] => test 1
)

 


AND THIS IS MY CODE FOR page2

<?php
session_start();


?>

<html>
<head>


<title>Send Message</title>

<?
  $BusinessName = addslashes($_POST['BusinessName']);

  $from = addslashes($_POST['from']);
  $status= addslashes($_POST['status']);
  $subject= addslashes($_POST['subject']);
  $message= addslashes($_POST['message']);

$BusinessName= $_SESSION['BusinessName'];
if(isset($_SESSION['BusinessName'])){
$query = "INSERT INTO  `messages` (`BusinessName`,`date`,`from`,`status`,`subject`,`message`)
VALUES ('".$_SESSION['BusinessName']."','".$date."','".$from."', '".$status."','".$subject."',
'".$message."')";

$result = mysql_query($query);
echo mysql_error();

if($result)
         {
echo mysql_affected_rows()." .Your Message have been sent. We will get back to you. <br>";
          }
}


?>


<center>





<pre>_SESSION:<?php print_r($_SESSION); ?></pre> This on page2 display[b] SESSION:Array
(
    [businessName] => 
    [test] => test 1
)[/b]

<table width="200" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td valign="top">
<?php include("includefiles/banner.php"); ?>
<td width="282"><? echo'<input name="from"  type="text" size="60">'; ?></td>
                            </tr>
                            <tr>
                              <td bgcolor="#CCCCCC"><strong>Subject </strong></td>
                              <td><? echo'<input name="subject" type="subject"  size="60">'; ?></td>
                            </tr>
                            <tr>
                              <td bgcolor="#CCCCCC"><strong>Body</strong></td>
                              <td><p>
                                <? echo'<textarea name="message" cols="75" rows="10"></textarea>'; ?>
                              </p>
                                <p> </p></td>
                            </tr>
                            <tr>

I am able to insert all the info exept for the BusinessName wich actually is not on page2 that is why is not going into the database

 

 

Link to comment
https://forums.phpfreaks.com/topic/55837-inserting-a-session-in-database/
Share on other sites

You might want to re-open your PHP again there.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

 

<? //Re-open the php here.

 

if(isset($_GET['BusinessName'])){

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.