Jump to content

Archived

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

gladiator83x

Alternative Way to Call a Variable

Recommended Posts

Hi All,

Is there anyway that I can pass a variable to another file besides using a hyperlink or some sort of form? This is the way that I have been doing it below: (string 11 is what was passed)

file 1:
echo '<form method="post" action=" confirm.php?string11=' . $hlink . ' "><br><br><br /><input type="submit" name="submit" value="Review Closure" />
</form>';
echo '</CENTER>';

file 2:
$title=$_GET['string11'];

Share this post


Link to post
Share on other sites
You can use sessions:

file 1:
[code]<?php
session_start(); // must be called at the start of each script where you use sessions.
$_SESSION['string11'] = $hlink;
?>[/code]

file 2:
[code]<?php
session_start();
$title = $_SESSION['string11'];
?>[/code]

Ken

Share this post


Link to post
Share on other sites
I tried using the session start function and I received these errors. I received this error when I put the session_start in the middle of the file; when I put it at the beginning of the file and try to echo out the variable that was passed, I received nothing. Anyone know what I am doing wrong?


Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /export/home2/webpages/more_metrics.php:6) in /export/home2/webpages/more_metrics.php on line 21



Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /export/home2/webpages/more_metrics.php:6) in /export/home2/webpages/more_metrics.php on line 21

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /export/home2/webpages/more_metrics.php:6) in /export/home2/webpages/more_metrics.php on line 21

Share this post


Link to post
Share on other sites
you have to include session_start to the file passing the variable AND the file receiving the variable. and you can only use this function BEFORE any output(or some headers) are sent to the browser.

Share this post


Link to post
Share on other sites
You have ouput at line 6 in more_metrics.php. Whats is at lines 4 - 8? If its output text/html/whitespace you cannot use session_start after the output. Make sure session_start(); is the first line of code for any page that needs session.

Share this post


Link to post
Share on other sites

×

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.