[PHP] Link shorter menu

User Tag List

Results 1 to 3 of 3
  1. #1
    Helstedxd's Avatar Active Member
    Reputation
    20
    Join Date
    Nov 2008
    Posts
    78
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [PHP] Link shorter

    Heey m8'ts
    I was bored so I made this:
    inc.php
    PHP Code:
    <?
    $dbhost = ""; //Your database host: localhost
    $dbuser = ""; //Your database user
    $dbpass = ""; //Your database password
    $db = ""; //Your database
    $url = ""; //Your webpage url
    ?>
    db.php
    PHP Code:
    <?

    mysql_connect ('$dbhost', '$dbuser', '$dbpass'); 
    mysql_select_db('$db');

    ?>
    index.php
    PHP Code:
    <?
    include('inc.php');
    if($id == ""){
    ?>
    <form action='?id=post' method='post'>
    Link: <input name='link' type='text'><input type='submit' value='Make short link'>
    </form>
    <?
    }elseif($id == "post"){
    if($_POST[link] == ""){
    echo "You have to write a link. <br><a href='?id='>Back</a>";
    }else{
    include('db.php');
    $secink = str_replace("http://", "", $_POST[link]);
    $dotiwithlink = "http://$secink";
    $random = substr(strtoupper(md5(uniqid("w"))), 0, 5);
    $create = "INSERT INTO links (link, rand) VALUES('$dotiwithlink', '$random')";

    mysql_query("$create");


    echo "New link <input type='text' size='100' value='$url/?id=show&what=$random'>";
    }}elseif($id = "show"){
    include('db.php');
    $result = mysql_query("SELECT * FROM links WHERE rand = '$what'");
    $row = mysql_fetch_array($result);
    ?>
    <script type="text/javascript">
    <!--
    window.location = "<?echo $row[link];?>"
    //-->
    </script>
    <?
    }
    ?>
    <!-- Copyright to me :D -->
    <center>Scriptet by Helstedxd</center>
    The SQL
    Code:
    CREATE TABLE `links` (
      `id` int(11) NOT NULL auto_increment,
      `link` text NOT NULL,
      `rand` varchar(255) NOT NULL default '',
      PRIMARY KEY  (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=1 AUTO_INCREMENT=1 ;
    Last edited by Helstedxd; 12-23-2008 at 07:14 PM.

    [PHP] Link shorter
  2. #2
    suicidity's Avatar Contributor
    Reputation
    207
    Join Date
    Oct 2006
    Posts
    1,439
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could absolutely be done without SQL, and SQL is a nuisance in my opinion; For the use of this script. Might help someone, yet I could think of multiple flat-file / re-directive approaches.


  3. #3
    insignia96's Avatar Banned
    Reputation
    33
    Join Date
    Oct 2008
    Posts
    304
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by genoke
    wont work
    /fail nice job idiot
    @Genoke Program it better asswipe. Also /report for you

    @Helstedxd

    GJ on this, i will give u +Rep cookie

    I do agree w/ suicidity if SQL DB is not neccasary it is always best not to use

    Still GJ
    Last edited by insignia96; 01-11-2009 at 08:34 PM. Reason: made it a bit clearer

Similar Threads

  1. .php problems
    By Etaile in forum Community Chat
    Replies: 6
    Last Post: 07-31-2010, 07:03 PM
  2. Joana video link
    By Dok-121 in forum World of Warcraft General
    Replies: 5
    Last Post: 11-20-2006, 07:39 AM
  3. anybody got links for Emu?
    By Krazzee in forum World of Warcraft General
    Replies: 4
    Last Post: 06-10-2006, 04:49 PM
  4. [Exploit] Warlock: Soul Linked Pets take no damage
    By Matt in forum World of Warcraft Exploits
    Replies: 3
    Last Post: 05-09-2006, 12:01 PM
All times are GMT -5. The time now is 01:11 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search