last day (15 days later) » 

9:20 PM
1
A: Display Different Phone # based referring page (PHP or JS)

JasonIF all these pages are on the same site, I would use sessions. On each page, set a session to something you can test against later. On one page: //Start session first session_start(); //Then choose a keyword to put in the single quotes & have it equal a unique number $_SESSION['page'] = ...

 
so if user came form somepage.html which is not listed in switch statement, how do I show default number?
 
add: default: $phone="number"
 
If user came from misite.com/aboutus.html how do I list that in switch statement?
 
On aboutus.html, set a session to a unique number not used on any other page... then add that to the switch statement, use corresponding phone number.
 
how would I do that (set session)?
 
9:20 PM
First, you must start sessions with: session_start(); THEN $_SESSION['page'] = a number
 
so I don't ask you a series of lead-on questions, can you provide sample code? For example I don
 
Hello
 
hI thanks for helping me
 
Sessions are a build in part of PHP
You have to start them first, on EACH page that uses them
with
session_start();
Then, choose a keyword to use everytime, the same word.. In this example, I used phone
err.. Page, not phone
$_SESSION['page']
then have it equal something
$_SESSION['page']=1;
OR just set it to a phone number
 
what if user came from index.html or aboutus.html? which does not use "PAGE"?
 
9:23 PM
$_SESSION['phone']="555-555-5555";
depends on if you are going to set a phone number, or a number to test against
look at my example, the default line is for when the test does not find anything
OR, if you set a phone number on each page, use a logic statment
my example spells it out for u
 
ok... i think I understand ... a little ... but you assume that my page structure has word PAGE ... it does not ... thare are many pages with
Ignor last MSG
 
noo
page is something u get
heh ok
u SET not get
typo
all you are doing is setting a number for each page.. that number is arbitrary, so is the session word
 
how do I set session number? is it part of URL ... like mysite.com/phone.html?ID=2
 
you could do $_SESSION['whocares']=3333333;
Its the number after the =
 
9:26 PM
the session number is after the -
=
you really dont know php eh?
 
I know on 101 level :)
not more
Intro to web programming class at community college
 
on 1 page, set $_SESSION['page']=1;
on another page, set $_SESSION['page']=2;
 
and so on
 
ok, so refering page shoud have $_SESSION['page']=1; line... and then page that shows the phonenumber have your code?
Now I thing I'm getting it
 
9:29 PM
You got it
Just make sure you start session first on ALL pages that use it'
even the phone number page
else it cant read what you set on referring page
 
ok, I will test it.
 
cool - key88crazy@gmail.com if you need anymore help
many many people helped me years ago when I started, so I like to give back!
 
So on phone # page, i can do $_SESSION['page']=phonepage; right?
 
no, you can test directly against $_SESSION['page']
OR, set a variable like this
$referingpage= $_SESSION['page'];
you would use that in the switch statment
switch ($_SESSION['page']) {
case 0:
$phone="555-555-5555";
break;
case 1:
$phone="555-555-5556";
break;
case 2:
$phone="555-555-5557";
break;
default:
$phone="555-555-5558";
}
OR
switch ($referringpage) {
case 0:
$phone="555-555-5555";
break;
case 1:
$phone="555-555-5556";
break;
case 2:
$phone="555-555-5557";
break;
default:
$phone="555-555-5558";
}
the last line, default: is for when no match is found
 
Ok, i will do some tests with this .... thank you Jason
 
9:32 PM
Your welcome! Happy coding.
 
will default show by itself if there is no match?
^_^ coding is mighty fun when you have ADD :)
i have ADD that is :)
Ok, I just reread your answer, and now it all makes sense :)
 

last day (15 days later) »