This may seem like a stupid question, but I can't find any good examples on this. I want to pass info through the URL, as in <!-- m --><a class="postlink" href="http://www.site.com?action=viewuser">http://www.site.com?action=viewuser</a><!-- m -->. Is there a specific way to do this?
I'm planning to make some pages with many functions, since I don't want to have millions of pages, I'll have just 1 which will display the info requested by the URL from a MySQL database.
Thanks.PHP includes
<!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=32364I've">http://www.htmlforums.com/showthread.ph ... =32364I've</a><!-- m --> tried that method, it dsen't work. Heres my code.
Test.php
<?
echo '<a href=http://www.htmlforums.com/archive/index.php/"test2.php?action=1">1</a><BR>
<a href=http://www.htmlforums.com/archive/index.php/"test2.php?action=2">2</a>';
?>
Test2.php
<?
$action=$_GET['action'];
if($action=1){
print'1';
exit;}
if($action=2){
print'2';
exit;}
?>
When I test it, it just says 1, even when I click on 2.shouldn't that be if($action==1) and if($action==2)
I may be wrong, still learning php.Tried that, doesn't work. Any other suggestions?<?php
// part1.php
echo '<a href=http://www.htmlforums.com/archive/index.php/"part2.php?action=1">1</a><br />
<a href=http://www.htmlforums.com/archive/index.php/"part2.php?action=2">2</a>';
?>
<?php
// part2.php
$action=$_GET['action'];
if($action==1){
print '1';
exit;
}
else
{
if($action==2){
print '2';
exit;
}
}
?>
Works perfectly. But the case/switch method might make more sense if you have a lot of alternatives. Example of switch is here (<!-- m --><a class="postlink" href="http://www.htmlite.com/php016.php">http://www.htmlite.com/php016.php</a><!-- m -->)Originally posted by wuzzuppy_123
Tried that, doesn't work. Any other suggestions?
works just fine
<?php
$action=$_GET['action'];
if($action=='1'){
print '1';
} elseif($action=='2'){
print '2';
}
?>Didn't work on my apache, but thanks guys, I got it working now. Thanks then you have something messed up on your end. that should have worked. and apache doesn't have anything to do with it.
if that didn't work then how did you get it working?I installed PHP differently on my apache (as a CGI, not as a module), I uploaded it to my paid server and messed with it a bit.
But do I sense some hostility, scoutt? I know it sucks to answer newb questions, but I do go looking for the answers before I come here. I was looking around for this answer for about a few days before I came here.
It is not my intent to be a bother to anyone.
Cheers I'm sure scoutt didn't mean for it to sound that way. Having 15000 posts i'm sure he's answered at least a few newb questions
The reason he asked how you fixed it is so other people might be able to gain from the information.Originally posted by wuzzuppy_123
I installed PHP differently on my apache (as a CGI, not as a module), I uploaded it to my paid server and messed with it a bit.
But do I sense some hostility, scoutt? I know it sucks to answer newb questions, but I do go looking for the answers before I come here. I was looking around for this answer for about a few days before I came here.
It is not my intent to be a bother to anyone.
Cheers
no it wasn't like it sounded. I run php as cgi and it works just fine. but I do have to comment, you can't upload it to your paid server, it has to be installed on the server. meaning they have to compile it and running it.
I'm planning to make some pages with many functions, since I don't want to have millions of pages, I'll have just 1 which will display the info requested by the URL from a MySQL database.
Thanks.PHP includes
<!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=32364I've">http://www.htmlforums.com/showthread.ph ... =32364I've</a><!-- m --> tried that method, it dsen't work. Heres my code.
Test.php
<?
echo '<a href=http://www.htmlforums.com/archive/index.php/"test2.php?action=1">1</a><BR>
<a href=http://www.htmlforums.com/archive/index.php/"test2.php?action=2">2</a>';
?>
Test2.php
<?
$action=$_GET['action'];
if($action=1){
print'1';
exit;}
if($action=2){
print'2';
exit;}
?>
When I test it, it just says 1, even when I click on 2.shouldn't that be if($action==1) and if($action==2)
I may be wrong, still learning php.Tried that, doesn't work. Any other suggestions?<?php
// part1.php
echo '<a href=http://www.htmlforums.com/archive/index.php/"part2.php?action=1">1</a><br />
<a href=http://www.htmlforums.com/archive/index.php/"part2.php?action=2">2</a>';
?>
<?php
// part2.php
$action=$_GET['action'];
if($action==1){
print '1';
exit;
}
else
{
if($action==2){
print '2';
exit;
}
}
?>
Works perfectly. But the case/switch method might make more sense if you have a lot of alternatives. Example of switch is here (<!-- m --><a class="postlink" href="http://www.htmlite.com/php016.php">http://www.htmlite.com/php016.php</a><!-- m -->)Originally posted by wuzzuppy_123
Tried that, doesn't work. Any other suggestions?
works just fine
<?php
$action=$_GET['action'];
if($action=='1'){
print '1';
} elseif($action=='2'){
print '2';
}
?>Didn't work on my apache, but thanks guys, I got it working now. Thanks then you have something messed up on your end. that should have worked. and apache doesn't have anything to do with it.
if that didn't work then how did you get it working?I installed PHP differently on my apache (as a CGI, not as a module), I uploaded it to my paid server and messed with it a bit.
But do I sense some hostility, scoutt? I know it sucks to answer newb questions, but I do go looking for the answers before I come here. I was looking around for this answer for about a few days before I came here.
It is not my intent to be a bother to anyone.
Cheers I'm sure scoutt didn't mean for it to sound that way. Having 15000 posts i'm sure he's answered at least a few newb questions
The reason he asked how you fixed it is so other people might be able to gain from the information.Originally posted by wuzzuppy_123
I installed PHP differently on my apache (as a CGI, not as a module), I uploaded it to my paid server and messed with it a bit.
But do I sense some hostility, scoutt? I know it sucks to answer newb questions, but I do go looking for the answers before I come here. I was looking around for this answer for about a few days before I came here.
It is not my intent to be a bother to anyone.
Cheers
no it wasn't like it sounded. I run php as cgi and it works just fine. but I do have to comment, you can't upload it to your paid server, it has to be installed on the server. meaning they have to compile it and running it.