Jump to content

Getting a value from another file

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
sergo

sergo

    Newbie

  • Members
  • Pip
  • 7 posts
Hi

I have a couple of php file that run separately, but I want to make them work together, how can I get the $val1 value from file1 to file2 so that $val1 can be used in the the second file?

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
There are methods:
1) if they link to eachother, by the link, add "?var=value" to the other filename
2) if same user uses them both, store in a session variable
3) store value in a file on disk
4) store value in a database
and there are maybe even more
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
cakka

cakka

    Programmer

  • Members
  • PipPipPipPip
  • 192 posts
the simple way is store the value on database, you need to
1. create database
2. create table
3. store the value

for get the value you can use SELECT mysql :)
good luck

#4
sergo

sergo

    Newbie

  • Members
  • Pip
  • 7 posts
how do I link them each other?var=value"

#5
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
just a link:

echo "<a href='file2.php?var=".$valuetosend."'>link to page 2</a>";

then read it in file2 with $_GET['var']
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#6
sergo

sergo

    Newbie

  • Members
  • Pip
  • 7 posts
I want to use this to search a data base but it is very confusing because I have several problems.

Edited by sergo, 22 October 2009 - 07:15 AM.