Jump to content

[SOLVED] SESSION POST?


amwd07

Recommended Posts

I am trying to insert data into 1 database field

$ins_restaurant_ratings->addColumn("rate", "STRING_TYPE", "SESSION", "ratings");

 

I can see the session is working because when I submit the commas are in the DB but no ne of the values are there?

 

So I know my implode works but my $_POST don't seem to show?

 

$service = $_POST['service'];
$atmosphere = $_POST['atmosphere'];
$cleanliness = $_POST['cleanliness'];
$value = $_POST['value'];
$experience = $_POST['experience'];

$ratings = array("$service", "$atmosphere", "$cleanliness", "$value", "$experience");
$ratings_combined = implode(",", $ratings);

session_start();
$_SESSION['ratings'] = $ratings_combined;

Link to comment
https://forums.phpfreaks.com/topic/79813-solved-session-post/
Share on other sites

I have now tried this and still not working can anyone point me on the right direction for this one please ???

 

if ($service != '') $service = $_POST['service'];
if ($atmosphere != '') $atmosphere = $_POST['atmosphere'];
if ($cleanliness != '') $cleanliness = $_POST['cleanliness'];
if ($value != '') $value = $_POST['value'];
if ($experience != '') $experience = $_POST['experience'];

$ratings = array("$service", "$atmosphere", "$cleanliness", "$value", "$experience");
$ratings_combined = implode(",", $ratings);

session_start();
$_SESSION['ratings'] = $ratings_combined;

Link to comment
https://forums.phpfreaks.com/topic/79813-solved-session-post/#findComment-404181
Share on other sites

I have tested to see if the session is working with print_r($_SESSION); before submit

 

Array ( [KT_lastsiteroot] => d0e619c8b5b8e6a9aa2b6a8e19f6a3be [service] => [atmosphere] => [cleanliness] => [value] => [experience] => [ratings] => ,,,, )

 

when I press submit my print_r now shows, anyone any idea's as why it is showing the array before submit?

 

Array ( [KT_lastsiteroot] => d0e619c8b5b8e6a9aa2b6a8e19f6a3be [service] => 4 [atmosphere] => 5 [cleanliness] => 4 [value] => 5 [experience] => 4 [ratings] => 4,5,4,5,4 )

Link to comment
https://forums.phpfreaks.com/topic/79813-solved-session-post/#findComment-404245
Share on other sites

// Make an insert transaction instance
$ins_restaurant_ratings1 = new tNG_insert($conn_connDW);
$tNGs->addTransaction($ins_restaurant_ratings1);
// Register triggers
$ins_restaurant_ratings1->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_restaurant_ratings1->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$ins_restaurant_ratings1->registerTrigger("AFTER", "Trigger_SendEmail", 98);
// Add columns
$ins_restaurant_ratings1->setTable("restaurant_ratings");
$ins_restaurant_ratings1->addColumn("rating_id", "NUMERIC_TYPE", "POST", "rating_id");
$ins_restaurant_ratings1->addColumn("rate", "STRING_TYPE", "SESSION", "ratings");
$ins_restaurant_ratings1->addColumn("accountname", "STRING_TYPE", "POST", "accountname");
$ins_restaurant_ratings1->addColumn("postcode", "STRING_TYPE", "POST", "postcode");
$ins_restaurant_ratings1->addColumn("email", "STRING_TYPE", "POST", "email");
$ins_restaurant_ratings1->addColumn("name", "STRING_TYPE", "POST", "name");
$ins_restaurant_ratings1->addColumn("comments", "STRING_TYPE", "POST", "comments");
$ins_restaurant_ratings1->addColumn("service", "NUMERIC_TYPE", "POST", "service");
$ins_restaurant_ratings1->addColumn("atmosphere", "NUMERIC_TYPE", "POST", "atmosphere");
$ins_restaurant_ratings1->addColumn("cleanliness", "NUMERIC_TYPE", "POST", "cleanliness");
$ins_restaurant_ratings1->addColumn("value", "NUMERIC_TYPE", "POST", "value");
$ins_restaurant_ratings1->addColumn("experience", "NUMERIC_TYPE", "POST", "experience");
$ins_restaurant_ratings1->addColumn("onhold", "NUMERIC_TYPE", "POST", "onhold");
$ins_restaurant_ratings1->setPrimaryKey("rating_id", "NUMERIC_TYPE");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rsrestaurant_ratings = $tNGs->getRecordset("restaurant_ratings");
$row_rsrestaurant_ratings = mysql_fetch_assoc($rsrestaurant_ratings);
$totalRows_rsrestaurant_ratings = mysql_num_rows($rsrestaurant_ratings);

$service = $_POST['service'];
$atmosphere = $_POST['atmosphere'];
$cleanliness = $_POST['cleanliness'];
$value = $_POST['value'];
$experience = $_POST ['experience'];


session_start();
$ratings = array("$service", "$atmosphere", "$cleanliness", "$value", "$experience");
$ratings_combined = implode(",", $ratings);
$_SESSION['ratings'] = $ratings_combined;

print_r($_SESSION); 

Link to comment
https://forums.phpfreaks.com/topic/79813-solved-session-post/#findComment-404253
Share on other sites

ahhhhhhhh I can't believe I missed that one thanks

I have now moved the code above the insert works perfect  ;D

 

$service = $_POST['service'];
$atmosphere = $_POST['atmosphere'];
$cleanliness = $_POST['cleanliness'];
$value = $_POST['value'];
$experience = $_POST ['experience'];

session_start();
$ratings = array("$service", "$atmosphere", "$cleanliness", "$value", "$experience");
$ratings_combined = implode(",", $ratings);
$_SESSION['ratings'] = $ratings_combined;

// Make an insert transaction instance
$ins_restaurant_ratings1 = new tNG_insert($conn_connDW);
$tNGs->addTransaction($ins_restaurant_ratings1);
// Register triggers
$ins_restaurant_ratings1->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_restaurant_ratings1->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$ins_restaurant_ratings1->registerTrigger("AFTER", "Trigger_SendEmail", 98);
// Add columns
$ins_restaurant_ratings1->setTable("restaurant_ratings");
$ins_restaurant_ratings1->addColumn("rating_id", "NUMERIC_TYPE", "POST", "rating_id");
$ins_restaurant_ratings1->addColumn("rate", "STRING_TYPE", "SESSION", "ratings");
$ins_restaurant_ratings1->addColumn("accountname", "STRING_TYPE", "POST", "accountname");
$ins_restaurant_ratings1->addColumn("postcode", "STRING_TYPE", "POST", "postcode");
$ins_restaurant_ratings1->addColumn("email", "STRING_TYPE", "POST", "email");
$ins_restaurant_ratings1->addColumn("name", "STRING_TYPE", "POST", "name");
$ins_restaurant_ratings1->addColumn("comments", "STRING_TYPE", "POST", "comments");
$ins_restaurant_ratings1->addColumn("service", "NUMERIC_TYPE", "POST", "service");
$ins_restaurant_ratings1->addColumn("atmosphere", "NUMERIC_TYPE", "POST", "atmosphere");
$ins_restaurant_ratings1->addColumn("cleanliness", "NUMERIC_TYPE", "POST", "cleanliness");
$ins_restaurant_ratings1->addColumn("value", "NUMERIC_TYPE", "POST", "value");
$ins_restaurant_ratings1->addColumn("experience", "NUMERIC_TYPE", "POST", "experience");
$ins_restaurant_ratings1->addColumn("onhold", "NUMERIC_TYPE", "POST", "onhold");
$ins_restaurant_ratings1->setPrimaryKey("rating_id", "NUMERIC_TYPE");

Link to comment
https://forums.phpfreaks.com/topic/79813-solved-session-post/#findComment-404267
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.