Jump to content

Alternative Way to Call a Variable


gladiator83x

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'];
Link to comment
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
Link to comment
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
Link to comment
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.
Link to comment
Share on other sites

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.