Artial submitter, game walkthroughs

Discussion in 'PHP' started by paul_so40, May 7, 2009.

  1. #1
    Hi all,

    To start of with ill exsplain what im doing.

    I am making a game walkthrough submitter script.

    How ever i have come across a few things i need some help with doing.

    Ok, so to start of with there are 2 text boxes

    The 1st one they write the game title in and 3rd one they add the walkthrough to.


    Then there is the a drop down box with 5 selections - these are the catagorys.

    1) Action & Adventure
    2) Driving & Racing
    3) Role-Playing Games
    4) War & Shoot 'Em Ups
    5) Sport

    On submit, it creates a page from a pre made template at file1.html

    wich consists of ( for example )
    php Code:

    <html>
    <head>
    <title>{REPLACE_TITLE}</title>
    </head>
    <body>
    MADE BY <b> {REPLACE_WITH_USERNAME} </b>
    IN CATAGORY <b> {REPLACE_CATAGORY} </b>
     <b> {REPLACE_DATA} </b>
    </body>
    </html>
    PHP:
    I need it to get the username as the logged in user, echo

    $vbulletin->userinfo['username'];
    PHP:
    so what i need is to modify the following script to do this, im just not sure on the script to fufill my needs. Also i would like it if it gives the file a random name ( so the same one is never used twice )

    php Code:
    
    <?php
        if(empty($_POST)) {
            ?>
            <form method="post">
               File Name <input type="text" name="name" size="20"><p>
               
                Game Name <input type="text" name="title" size="22"></p>
               <p>
               
                &nbsp;Walkthrough - use as much space as you like<br>
                &nbsp;<textarea rows="16" name="content" cols="51"></textarea><br>
    
                <input type="submit" value="Create"> </p>
            </form>
    <?php
            die();
        }
    
    $name = $_POST['name'];
    $title = $_POST['title'];
    $content = $_POST['content'];
    
    $sanitized_name = preg_replace('/[^0-9a-z\.\_\-]/i','',$name);
    if ($sanitized_name == $name) {
     
            $data = file_get_contents("templates/file1.html");
            if(get_magic_quotes_gpc())
                $data = stripslashes($data);
            $data = str_replace("{REPLACE_TITLE}",$title,$data);           
            $data = str_replace("{REPLACE_DATA}",$content,$data);
           
            write_file("$name.php",$data);
    
    
    
    } else {
      echo "Filename problems.  Try ".$sanitized_name;
      exit;
    }
    
        function write_file($filename,$data) {
            $f = fopen($filename,"w");
            fwrite($f,$data);
            fclose($f);
        }
    
    
    
    ?>
    PHP:
    also this script creates the script to the folder
    /catagorychosen/
    Code (markup):
    i would like it to create it into the folder depending on what category they place it under.

    The reason for me not doing this by mysql is because i have no idea on what im doing with mysql, unless thers someone willing to walk me through step by step as i do it, so all im realy doing is copy and pasting and doing things as im told to do it, or is willing to, with an ftp account, do it for me, then html form posting is my only option, since i know more about what im doing with it lol.

    Any questions just ask

    Thanks - all help is apreceated.

    - Paul
     
    paul_so40, May 7, 2009 IP
  2. paul_so40

    paul_so40 Peon

    Messages:
    119
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can anyone help?
     
    paul_so40, May 8, 2009 IP