Jump to content

Dumbest question ever - Passing a variable without a form


quadlo

Recommended Posts

HI all,

 

Complete newbie - first ever time trying to use PHP.

 

So, here's the problem - I have a piece of data I want to pass to a php page, don't want it to show in the url, so guess i need to use $_POST.

 

I've tried the following with no success - since I'm learning php at the same time I'm trying to get something to work - I feel real stooooopid - any help would REALLY be appreciated.

 

$_POST['Barid'];

// Barid will contain a 3 character code, first is a letter, next 2 are numbers eg: "A12"

 

the code then calls the next page in and I try to retrieve the info

 

$Barid = $_POST['Barid'];

 

Result is that $Barid is blank

 

I'm sooooooooo confused.

I have been working on this problem all day (over 5 hours). Seems like there aught to be a way to pass a simple variable to the next script.

 

Here is what I ended up with....

<?php

echo "Start the session....";

Session_start(); // Start the PHP session

$Barid = "A34"; // Constant for now

$_SESSION['Barid'] = $Barid; // Pass  dentifier to next page

?>

It works - THE FIRST TIME it's run!!!!!

 

When I run it again (as will happen many time in the application) I get the following error (have spent hours reading the php manual trying to figure a way out of this - no luck)

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\RickDB\h-3.php:2) in C:\xampp\htdocs\RickDB\h-3.php on line 4

 

Really - I can't see that it would be that hard to do what I want - I can think of literally dozens of ways to do it on mainframes (I've been in I.T. for over 40 years). Can anyone just show the 3 or 4 lines (probably) of code that will make this happen?

 

Thanks for all the previous help - but, well, since this is brand new to me - I just am not getting it.

 

Quadlo

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.