Jump to content

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


Trevors

Recommended Posts

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
[code]
<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;">
[/code]

I then catch it in another file using $_GET
[code]
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>';
}
[/code]


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
Link to comment
Share on other sites

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

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

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


So with your problem you'll wnat to do this:
[code=php:0]// dont for get to start the session

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

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.