Jump to content

Write this Code onto a File?


Warptweet

Recommended Posts

I have this code...
[code]<A HREF="javascript:void(0)"
ONCLICK="window.open('http://www.google.com','miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=300')">Open A Window</a>
[/code]

How can I write that code to http://www.warptweet.com/2116121514119/$randnum?
By the way, $randnum is the file that was uploaded.

I use fopen with the w (write)

I think it gives me an error because that javascript has a "'s in it, how can I resolve the "'s?
Link to comment
https://forums.phpfreaks.com/topic/34061-write-this-code-onto-a-file/
Share on other sites

This works for me, notice I put a '\' in front of each ".

[code]
<?php
// Escape the offending character :)
$text = "<A HREF=\"javascript:void(0)\"
ONCLICK=\"window.open('http://www.google.com','miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=300')\">Open A Window</a>";
$file = "myfile.html"; 
if (!$my_file = fopen($file,"a")) {
  echo "Unable to open $file";
  }
if (!fwrite($my_file, $text)) {
  echo "Unable to write to $file";
  }
echo "Text entered into $file"; 
fclose($my_file);
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.