Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Add Another PHP... "URL Thing" To The Current One?
Old 11-13-2009, 04:40 PM Add Another PHP... "URL Thing" To The Current One?
Physicsguy's Avatar
404 - Title not found

Latest Blog Post:
Challenges
Posts: 824
Name: Scott
Location: Ontario
Trades: 0
I don't know what they're called, but here's an example:

http://www.example.com/page.php?whatever=something

The bold stuff. Now I have a script that is on a page with the URL as:

http://www.pgreviews.com/userreview.php?reviewID=2

(don't go there, it's not fully functionable yet )

And on that page, I have a script that sets ?comments to "on".
So the whole URL should be:


http://www.pgreviews.com/userreview....=2&comments=on

Right?

It doesn't work for me.

It just takes me back to userreview.php?comments=on.

How can I get it so that it adds it to the one already there, keeping reviewID as whatever it is?

Thanks!
__________________
Check out my
Please login or register to view this content. Registration is FREE

Last edited by Physicsguy; 11-13-2009 at 04:47 PM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-13-2009, 05:10 PM Re: Add Another PHP... "URL Thing" To The Current One?
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
Its called URL parameters.

I'm not quite understanding what the problem is. Is your script redirecting to userreview.php?comments=on? Posting your code would probably make it easier to see what you are doing wrong.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-13-2009, 05:26 PM Re: Add Another PHP... "URL Thing" To The Current One?
Physicsguy's Avatar
404 - Title not found

Latest Blog Post:
Challenges
Posts: 824
Name: Scott
Location: Ontario
Trades: 0
I can't really post the code, since it's all over the place and between two pages.

I'll try to give it a 'story' feel to it.

1. You go to userreview.php.
2. You click a button so the URL changes to userreview.php?comments=on
3. Now Comments are displaying.
4. Now you click a button to go to reviewID=2. reviewID is the ID of the review, it takes you to a unique page.
5. Now, you're at userreview.php?reviewID=2. But wait, didn't I say to keep the comments on? They're not there any more.
6. You'll turn them back on. You click the button.
7. Now you're back at userreview.php?comments=on. But I want to look at reviewID=2 and comments=on at the same time! I want the URL to be userreview.php?reviewID=2&comments=on!

I hope that helps. Now you could just type that in, and it would work, but many people out there don't know PHP () so they can't do that. So I made buttons that when you click them, it does it for you. But it can only have one URL parameter in the URL at a time.
__________________
Check out my
Please login or register to view this content. Registration is FREE

Last edited by Physicsguy; 11-13-2009 at 05:28 PM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 11-13-2009, 06:25 PM Re: Add Another PHP... "URL Thing" To The Current One?
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
Once comments is set to on, use a session variable to determine whether or not comments are displayed:
PHP Code:
session_start();

if(
$_GET['comments'] == 'on')
     
$_SESSION['comments'] = 1;
else if(
$_GET['comments'] == 'off')
     
$_SESSION['comments'] = 0;
//if $_GET['comments'] isn't set leave the previous value

if($_SESSION['comments'] == 1)
{
     
//display comments

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 11-13-2009 at 06:49 PM..
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-14-2009, 09:09 AM Re: Add Another PHP... "URL Thing" To The Current One?
Physicsguy's Avatar
404 - Title not found

Latest Blog Post:
Challenges
Posts: 824
Name: Scott
Location: Ontario
Trades: 0
Thank you so much! This works like a dream! I'll post back if I get any bugs or questions, thank you!
__________________
Check out my
Please login or register to view this content. Registration is FREE
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 11-14-2009, 10:29 AM Re: Add Another PHP... "URL Thing" To The Current One?
Super Spam Talker

Latest Blog Post:
PSD Squirrel Launched
Posts: 933
Trades: 7
Build your apps with cakephp , a php framework.. it takes care of all that for you and speeds up development time massively
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Sir P is offline
Reply With Quote
View Public Profile Visit Sir P's homepage!
 
Old 11-14-2009, 04:29 PM Re: Add Another PHP... "URL Thing" To The Current One?
Physicsguy's Avatar
404 - Title not found

Latest Blog Post:
Challenges
Posts: 824
Name: Scott
Location: Ontario
Trades: 0
I get this error with NullPointer's code:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/pgreviews/web/userreview.php:9) in /home/pgreviews/web/userreview.php on line 181

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/pgreviews/web/userreview.php:9) in /home/pgreviews/web/userreview.php on line 181

IDK, When I take out the session start line, it works, no errors, but it doesn't remember comments are on.
__________________
Check out my
Please login or register to view this content. Registration is FREE
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 11-14-2009, 04:49 PM Re: Add Another PHP... "URL Thing" To The Current One?
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
You cannot send any headers before calling session_start(). That means you can't have any output or calls to header() prior to calling session_start().
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-14-2009, 07:10 PM Re: Add Another PHP... "URL Thing" To The Current One?
Physicsguy's Avatar
404 - Title not found

Latest Blog Post:
Challenges
Posts: 824
Name: Scott
Location: Ontario
Trades: 0
Here's the full code to my page:

PHP Code:
<?php include "pgcdconfig.php"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Physicsguy's Reviews - User Review</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="Scott Kaye" />
<meta name="description" content="PGReviews - User review.  This is a review submitted by one of our users." />
<meta name="keywords" content="Review, reviews, user, pgcd, pg, pgcreatedata, " />
<link rel="stylesheet" href="physicsguystyle2.css" type="text/css" media="screen" />
<link rel="stylesheet" href="pgcdstyle.css" type="text/css" media="screen" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="lavatheme" href="physicsguystyle.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="rocktheme" href="physicsguystyle3.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="darkmattertheme" href="physicsguystyle4.css" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<link rel="icon" href="images/favicon.ico" type="image/x-icons" />
<meta name="viewport" content="initial-scale = 1.0" />
<script type="text/javascript" src="getscreen.js"></script>
<!--This script should appear below your LINK stylesheet tags -->

<script src="styleswitch.js" type="text/javascript">
/***********************************************
* Style Sheet Switcher v1.1- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
</head>
<body>
<div id="container"><div id="banner">
<div id="brb" >
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<script type="text/javascript">

function showbox()
{
    document.getElementById("togglebox").style.display="block";
}
function hidebox()
{
    document.getElementById("togglebox").style.display="none";
}
</script>

<div id="togglebox" onclick="showbox()">
<div class="contentboxtitle">
<form action="" method="get">
<table><tr><td><input name="reviewID" title="Enter a Review ID in this box to go straight to that review!" />&nbsp;<input type="submit" value="Go" /></td></tr></table>
</form>

</div>
</div>

<p style="background:black;width:150px;float:right;text-align:center;padding:0px;"><span class="togglebuttons" onclick="showbox()">Show</span> | <span class="togglebuttons" onclick="hidebox()">Hide</span></p>
</div>
</div><div id="wrapper"><div id="main">
<script type="text/javascript">
if (pageWidth() < 400) {
document.writeln('<link rel="stylesheet" type="text/css" href="mobilestyle.css" />  <h3>You are browsing Physicsguy\'s Reviews in mobile mode.  All of the features are here, nothing has changed, other than the size and functionality of this site!  <br /><br />  ');
}
</script>
<script type="text/javascript">
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
if (document.cookie.indexOf("iphone_redirect=false") == -1)
document.writeln('<link rel="stylesheet" type="text/css" href="mobilestyle.css" />');
}</script>
<!--Begin main content-->

<!--
Database puller and accesser by Chris Hester, www.designdetector.com
-->


<?php

$reviewID 
$_GET["reviewID"]; //Set the variable 'reviewID' as from the URL.

if ($reviewID == "") {
echo 
'
<div class="contentboxtitle">
<h1>User Reviews</h1>
</div>
<div class="contentbox">
<p>Use the search box below this text to find the review you are looking for!</p>
</div>
<div class="contentbox">
'
;

$countdelims =  file_get_contents("ffdatabase.txt");
$delimnum substr_count($countdelims'|');
$entrynum $delimnum 1;
$numofentriestoshow1 "2";
$numofentriestoshow2 "1";
echo 
"<p>Currently, there are $entrynum entries.  Below, you can find links to the last $numofentriestoshow1 entries.</p>";
$last1 $delimnum $numofentriestoshow1;
$last2 $delimnum $numofentriestoshow2;

$pathtouserreview "userreview.php";  //if you're going to use file_get_contents, make sure to put the WHOLE URL (FULL PATH) in.

$lastlink "$pathtouserreview?reviewID=$last1";
$lastlink2 "$pathtouserreview?reviewID=$last2";




//$getlast = file_get_contents("$lastlink");
//$getsecondlast = file_get_contents("$lastlink2");


echo "<a href='$lastlink2'>Most Recent</a>";
echo 
"<br />";
echo 
"<a href='$lastlink'>Second Last</a>";


echo 
"</div>";


}

$editable $_GET["edit"];

$transback = array(
"\n" => "<br />",
"@#$AdminPassword#@" => "$AdminToPostAs",
); 
//Simply changes all line breaks in the text file to <br/>s, feel free to add more, just don't delete that line.

$string file_get_contents("ffdatabase.txt");
$strings explode('|',$string);
$stringtotrans $strings[$reviewID];
$stringtrans strtr("$stringtotrans"$transback);

//Find Password Script//
$wholeReview "$stringtrans";

$wholeReview split('=-=-'$wholeReview);

$FindPassword "$wholeReview[1]";
echo 
"$FindPassword";

if (
$editable == $FindPassword) {
echo 
"<p><b><span style='color:lightgreen;'>yayz!  it workz!</span></b></p>";
}
else if (
$editable == "") {
echo 
"Edit this review with the password you made when you wrote it.";
}
else if (
$editable != $FindPassword) {
echo 
"<p><b><span style='color:red;'>Wrong Password</span></b></p>";
}

if (
$reviewID == "0") {
echo 
"
<br />
<p>The review you are looking for does not exist.</p>
<p>Please enter a number from 1+.</p>
"

}
else if (
$reviewID != "") {
echo 
"<div class='contentboxtitle' style='float:right;height:30px;'><form action='' method='get'><input type='text' name='edit' /><input type='submit' value='Submit' /></div></form>$stringtrans"//Echo the review
}




?>



<hr />
<div class="contentboxtitle">
<h1>Commenting</h1>
</div>
<div class="contentbox">
<p>Check this box to allow Comments.</p>
<?php 
$currentURL 
"/userreview.php?reviewID=$reviewID";
echo 
$currentURL?>
<form>
<input type="checkbox" checked="checked" name="comments" />
<?php echo "<a href='$currentURL&comments=on'>Turn $OnOff Comments</a>"?>
</form>
<?php
$CommentingStatus 
$_GET["comments"];
if (
$CommentingStatus == "on") {
echo 
"<p style='color:#06fb08;font-weight:bold;'>Comments are currently on.</p>";
}
else if (
$CommentingStatus != "on") {
echo 
"<p style='color:red;font-weight:bold;'>Comments are currently off.</p>";
}
;
?>
</div>
<?php
$string 
$_GET["text"];
$patterns[0] = '/quick/';
$patterns[1] = '/brown/';
$patterns[2] = '/lazy/';
$replacements[0] = 'GIGANTIC';
$replacements[1] = 'yellow';
$replacements[2] = 'frickin\'';
echo 
preg_replace($patterns$replacements$string);

echo 
"<br />";

session_start(); 

if(
$_GET['comments'] == 'on'
     
$_SESSION['comments'] = 1
else if(
$_GET['comments'] == 'off'
     
$_SESSION['comments'] = 0
//if $_GET['comments'] isn't set leave the previous value 

if($_SESSION['comments'] == 1

     
//display comments 
}

if (
$EnableCommenting == "yes") {
$ShowComments $_GET["comments"];
if (
$ShowComments == 'show') {
echo 
"SHOWING!";
}
}
else if (
$EnableCommenting == "no") {
echo 
"No Comments allowed!";
}

?>

<!--SCRIPT FOR COUNTING COMMENTS AND SPLITTING THEM INTO PAGES.  REPEAT ECHOING THE COMMENTS UNTIL THE COMMENT # REACHES 10, THEN MAKE BUTTON THAT SAYS 'MORE...', WHICH DISPLAYS ANOTHER 10.-->
<?php
$i
=1;
while(
$i<=10)
  {
  echo 
"The number is " $i "<br />";
  
$i++;
  }
?>

<!--End main content-->

</div></div><div id="extension">

<!--Begin right side content-->

<?php include("form.html"); ?>
<?php 
include("stylebuttons.htm"); ?>

 <h2>Other Links</h12>
  <hr>                      
  <h3><a href="reviews.shtml">Go Back</a></h3>
  <hr>                    
  <a href="index.html">Back To Welcome</a>

<?php include("rightsidemenu.htm"); ?>

<hr />

<a href="setup.shtml">Settings</a>

<!-- End right side content -->

</div><div id="navigation"><div id="navmenu"><ul>

<!-- Begin navigation links...add as necessary -->

<?php include("leftsidemenu.htm"); ?>

<!-- End navigation links -->

</ul></div></div>

<div id="footer"><p class="footspace">&copy; 2009 Physicsguy | <a href="setup.shtml">Settings</a></p></div></div>
</body>
</html>
It's very messy, because I'm experimenting with different things at the same time, but I don't think I'm calling any headers before session start...
__________________
Check out my
Please login or register to view this content. Registration is FREE
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 11-14-2009, 10:21 PM Re: Add Another PHP... "URL Thing" To The Current One?
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by NullPointer View Post
You cannot send any headers before calling session_start(). That means you can't have any output or calls to header() prior to calling session_start().
Any output whether it be a call to echo or code outside of the php tags before a call to session_start will send headers. Putting session_start at the top of the script will solve the problem.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-14-2009, 11:20 PM Re: Add Another PHP... "URL Thing" To The Current One?
Physicsguy's Avatar
404 - Title not found

Latest Blog Post:
Challenges
Posts: 824
Name: Scott
Location: Ontario
Trades: 0
Quote:
Originally Posted by NullPointer View Post
Any output whether it be a call to echo or code outside of the php tags before a call to session_start will send headers. Putting session_start at the top of the script will solve the problem.
So I just stick session_start right at the top of my page? Just put <?php session_start() ?> at the beginning?
__________________
Check out my
Please login or register to view this content. Registration is FREE
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 11-14-2009, 11:54 PM Re: Add Another PHP... "URL Thing" To The Current One?
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
That should do it. As long as you start the session at someplace in your script you'll be able to store session variables. Doc: http://php.net/manual/en/function.session-start.php
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to Add Another PHP... "URL Thing" To The Current One?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46477 seconds with 12 queries