Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: PHP Help please

  1. PHP Help please

    I have a PHP question. Lets say I have a page that has a variable, say, $poop = $_GET['butt']. So the URL woudl be, like, www.mysite.com/goatse.php?butt=ass or something.

    But is it possible for me to write some code in goatse.php where I can just enter www.mysite.com/goatse.php, and I dont need to define something for butt - the preprocessor would just ignore it.

    Also, if you cant or whatever, whats good PHP principles in this situation? Im trying to design without a PHP book, so any help would be great.

  2. Quote Originally Posted by diffusionx
    I have a PHP question. Lets say I have a page that has a variable, say, $poop = $_GET['butt']. So the URL woudl be, like, www.mysite.com/goatse.php?butt=ass or something.

    But is it possible for me to write some code in goatse.php where I can just enter www.mysite.com/goatse.php, and I dont need to define something for butt - the preprocessor would just ignore it.

    Also, if you cant or whatever, whats good PHP principles in this situation? Im trying to design without a PHP book, so any help would be great.
    When you're passing variables to PHP through the GET method either in a form or just adding stuff after a hyperlink, that's what the question mark is used for. If you want otherwise you have to use a form and use the POST method. If you're doing this for hyperlinks, then you'd have to use class definitions in CSS to make the buttons look like links, for example:

    Code:
    CSS:
    
    .linkbutton {
         background: #fff;
         border: 1px solid #fff;
         color: #069;
         text-decoration: underline;
    }
    PHP Code:
    <?php
         $poop 
    $_POST['butt'];
         
    /* stuff to do with the variable here */
    ?>

    <!-- EACH LINK LOOKS LIKE THIS: -->
    <form action="goatse.php" method="post"><input type="hidden" name="butt" value="link1" /><input class="linkbutton" type="submit" name="submit" value="Link #1" /></form>
    That would be a pain in the ass for each link so what I usually do is if my GET variable is empty or invalid, just redirect to the main page.

  3. Well I changed it to POST, how can I detect if the POST is empty? So, like, lets say:

    $poop=$_POST['goatse']

    If goatse is empty or invalid, how do I even test for that?

    How do I test if GET is invalid or empty?
    Last edited by diffusionx; 22 Apr 2005 at 09:30 PM.

  4. Code:
    <?php 
    if ( isset($_GET['butt']) ) { 
      $poop = $_GET['butt'];
    //code for if butt was read from querystring
    } else {
    //regular code when not present
    }
    ?>
    You trying to design without the use of google as well? And you don't need to use the post method for this btw. Extra testing in the below sample to avoid errors:
    Code:
    $filename = '';
    if ( isset($_GET) && isset($_GET['fileName']) ) {
      $filename = $_GET['fileName'];
    }
    $filename = realpath($filename);
    if ( !empty($filename) ) { ...do something...}
    Last edited by NightWolve; 22 Apr 2005 at 11:45 PM.
    "Don't be a pansy." - James

  5. Nah, Google has given me most of the answers I needed, just not this one.

  6. Check my quick edit. That it? An extra "isset($_GET)" test? Don't see anything else based on your question. You getting some error message?
    Last edited by NightWolve; 22 Apr 2005 at 11:49 PM.
    "Don't be a pansy." - James

  7. It seems to work fine. Thanks.

  8. Yeah, NW has a good suggestion. Here's basically what I do:

    PHP Code:
    <?php

         $url 
    'http://www.mysite.com/index.php?area=main';
         
    $area $_GET['area'];

         
    /* sql query to get list of valid areas or you can
            just specify the list in an array like:
            $allowed = array( 'one', 'two', 'three' ); */

         
    if( array_key_exists$area$allowed ) ) {
              require( 
    "modules/{$area}.php" );     // code for valid area
         
    } else {
              
    header"Location:{$url});          // redirect
         
    }

    ?>

  9. $poop = ($_GET['ass']) ? $_GET['ass'] : "";

    hooray for simplification

  10. Is there a size limit to the TEXT datatype in MySQL? I was doing some testing on my code and it seems to return an error when the text is too long. I tried switching the datatype to BLOB but that didnt really work, either. Any suggestions? What I mean by "long" is about maybe 600 words worth of shit. This problem has kinda de-motivated me but I dont want to shelve all the work I did especially since I was like, *days* from launching the site.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Games.com logo