Hey, I'm testing with a lil PHP script. What I'm doing is a small web app like tinyurl.com. Right now it works good except for one thing. I would like for users to have to option of creating their own url (ex. instead of the randomly generated numbers/letters they can use their own text, like myurl.com/hello or myurl.com/coolcar or whatever).
Right now it just randomly generates some numbers/letters for their url or they can go to another page to enter their custom url. I would like to enable it to do both where if the user does not enter a custom url then it will randomly generate the url for them.
If you would like to see the site http://wiurl.com an for creating ur own url http://wiurl.com/index2
Below is The code
Code: Select all
<form name ="url" method="post" class="style2">
<div align="center">Your Long URL:
<input name="oldurl" type="text" size="28">
<br>
Wi URL: http://wiurl.com/
<input name="newurl" type="text" size="21" />
<br />
<input type="submit" name="submit" value="Make it Wi">
<br />
Number of Wi URL's:
<?PHP // Hit counter //
$count_my_page=("hitcounter.txt");
$hits = file($count_my_page);
$hits[0]++;
$fp = fopen($count_my_page , "w"); // Open File
fputs($fp , "$hits[0]");
fclose($fp);
echo $hits[0];
// end pageviews ?>
</div>
</form>
<span class="style2">
<?php
if ($_POST['submit']) {
$log=fopen("log1.html","a");
if( !$log ) {
} else {
fwrite($log, "Date: " .date('l dS \of F Y h:i:s A') . ", IP:" . $REMOTE_ADDR . "<br>");
fclose($log);
}
$rnd_url=chr(rand(97,122)).chr(rand(97,122)).chr(rand(97,122)).chr(rand(97,122)); // Later Add .rand(111,999)
$newurl = $_POST['newurl'];
$oldurl = $_POST['oldurl'];
$title= $_POST['title'];
$urlcloking= $_POST['urlcloking'];
$redirect = "<html><head><title>$title</title></head><body>
<iframe src='$oldurl' height='100%' width='100%' frameborder='0'>
</script></body></html>";
if(file_exists("$newurl/index")) die("Please try again there was an error.");
mkdir("$newurl");
$filename = "$newurl/index";
$filename .= ".php";
$Content = "<META http-equiv='refresh' content='0;URL=$oldurl'>";
$handle = fopen($filename, 'x+');
fwrite($handle, $Content);
fclose($handle);
?>
<br>
</span>
<h2 class="style1"><marquee>Success!</marquee></h2>
<span class="style2">Your new URL is <a href=http://wiurl.com/<?php echo "$newurl"; ?>>http://wiurl.com/<?php echo"$newurl"; ?></a><br />
Copy your URL <input type="text" class="text" id="chi2" size="18" value="http://wiurl.com/<?php echo "$newurl"?>" onclick="this.select();" />