Jump to content


Photo

Trying to move html code through the url and catch it with $_GET


  • Please log in to reply
4 replies to this topic

#1 Trevors

Trevors
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 28 September 2006 - 07:16 AM

Heya all,
Im currently trying to make a myspace tool where you colorize text of yours in different colors.
Im moving the html code through the url and i then catch it with $_GET in another php file.

I print the $output into the url, faded.php?output=$output
<iframe frameborder="0" name="preview" width="627" src="faded.php?output=<?print $output;?>" height="187" style=margin:0px;padding:0px;></iframe></div>
<div id="Layer1" style="position:absolute; left:10px; top:216px; width:283px; height:118px; z-index:1; visibility: visible;">

I then catch it in another file using $_GET
if(!isset($_GET['output'])){
	$output = "";
}else{
	$output = $_GET['output'];
	$output = str_replace("~", "#", $output);
	Print'	<div id="Layer3" style="position:absolute; left:0px; top:0px; width:627px; height:187px; z-index:3; background-color: #000000; layer-background-color: #000000; border: 1px none #000000">' . $output . '</div>';
}


The problem is that i cant type very long text, is there a limit on how much the url can store?
If so what other ways are there?


Best Regards
Trevors

#2 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 28 September 2006 - 07:19 AM

In this case I would use a $_SESSION or a hidden $_POST field.

#3 Trevors

Trevors
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 28 September 2006 - 11:12 AM

how would the session work?
Could you code a bit so i could see how you mean.


Best Regards

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 28 September 2006 - 02:30 PM

To starta  session add the follow at the very top of every page, prefereably on line 1, that will use sessionss:
<?php session_start(); ?>

Now to set/read a session:
// set a session var:
$_SESSION['session_var_name_here'] = 'some value';

//read session var:
echo $_SESSION['session_var_name_here'];


So with your problem you'll wnat to do this:
// dont for get to start the session

$_SESSION['htmlStuff'] = <<<HTML
add your html code here
HTML;

Tnen on the page you wnat to use the html you can access it using $_SESSION['htmlStuff'] variable, agian dont forget to added session_start(); at the top of the page.

Also make sure THERE IS NO OUTPUT before you use the session_start function. Otherwise your page may fail to load or you'll get a header already sent error message.

#5 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 28 September 2006 - 02:36 PM

Yes The GET method has a limit while the POST method does not. You cannot exceed 100 characters in the value for the GET method




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users