?
Solved

How do I pass values from a URL into my site ?

Posted on 2003-02-25
16
Medium Priority
?
179 Views
Last Modified: 2010-04-09
Hi,

Im attempting to create a website that needs to change a few details within the HTML depending on the URL, for example...

www.somedomain.com/index.html?XS-100?200?100?19.95 etc

Then how do I get the code on the website to show these figures how I choose on the site

Regards
0
Comment
Question by:MirageSF
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
  • 2
16 Comments
 
LVL 1

Expert Comment

by:Jonza
ID: 8023266
i'm not sure that you can do that with only HTML.
but i'm 100% sure that is possible with PHP :)
0
 
LVL 2

Expert Comment

by:IeuanJ
ID: 8023762
You would need to use some form of scripting language to add dynamic content, ASP or PHP are prime candidates.  The below is an example of how this can be done with ASP/VBScript and the URL of "index.html?test=IeuanJ" where IeuanJ is an example of a username.

...  
<% If request.querystring("test")="IeuanJ" Then %>
   ...  'add Ieuanj content  ...
<% If request.querystring("test")="Wally" Then %>
   ...  'add Wally content  ...
<% If request.querystring("test")="Jane" Then %>
   ...  'add Jane content  ...
<% If request.querystring("test")="Jurgen" Then %>
   ...  'add Jurgen content  ...
<% Else %>
   ...  'add no-one content  ...
<% End If %>
...  
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8023837
with php
<?php
  if(isset($variable)){
    print("the content you want printed when the url has ?variable=something");
  }
?>
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 2

Expert Comment

by:IeuanJ
ID: 8023892
Cheers Jonza, not got into PHP yet, darn workplace wants to stick with ASP - VB - Visual, in fact its an MS Hell :(
0
 

Author Comment

by:MirageSF
ID: 8025343
Cool Jonza that works ok, but I really need to be able to address a single variable in the html, basically www.test.com/index.php?ds=200dt=2.5price=$4.95 etc, so how at the chosen location can I put say <?php print ("ds") ?> and it just shows the value for that variable ?

Regards
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8025372
no quite.
if you put variable to url like this index.php?ds=something
you can print it like this
<?php print($ds); ?>  <-- prints "something"
remember the $ because it has to be in front of every variable in php.
0
 

Author Comment

by:MirageSF
ID: 8025499
Perfect, one last thing before I end this question, is it possible to get the print(ds) etc when its inserted into the html, for this to take on the size, type etc of the font in use ?  As where some of these variables need to go the text is quite large, but when the variable is printed it goes in small!

Regards
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8025521
yes it is!

www.somedomain.com/index.php?fontsize=3
<font size="<?php print($fontsize); ?>">Some text</font>
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8025541
you can also check that if some variable exists like this:
<?php
if(isset($fontsize)){
   print("<font size='$fontsize'>sometext</font>");
}
else{
   print("<font size='1'>sometext</font>
}
?>

if fontsize is set it prints the text with that size and if not it uses default size 1 =)
0
 

Author Comment

by:MirageSF
ID: 8025664
What have I done wrong here ?  Trying to get it if value EA=999 then print unlimited else print the value of ea

if(isset($ea=999)){
  print("Unlimited");
}
else{
  print($ea
}
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8025689
no it doesn't work like that
if you want to compare the variable do it like this
if($ea == 999){
}

0
 
LVL 1

Accepted Solution

by:
Jonza earned 200 total points
ID: 8025708
if(isset($ea)){
    print("there is variable ea<br>");
    if($ea == 999){
        print("YES ea = 999");
    }
    else{
        print("No ea is $ea");
    }
}
else{
    print("variable ea is not set");
}

that should help you understand the difference =)
0
 

Author Comment

by:MirageSF
ID: 8025725
God damn its C ! lol, about time I got some sleep me thinx :)  Thanx for your help Jonza, and your blinkin' fast !

Best Regards

Wayne
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8025740
no problem
glad i could help
0
 

Author Comment

by:MirageSF
ID: 8026513
Sorry to bother u again, but how do I clear the URL bar from http://www.test.com/index.php?v1=1&v2=3 etc so the bar just shows http://www.test.com

Thanx
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8031353
you cant modify it with any script but if you redirect to some other url that will ofcourse change.

php redirect

header("Location http://test.com");
//headers must be before any other output
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question