Php Help

CurveCurve Join Date: 2003-12-17 Member: 24475Members, Reinforced - Shadow
<div class="IPBDescription">Passing PHP URL variables</div> Could some one help me with Passing PHP URL variables so it show a message in some content.

Comments

  • LinkLink Join Date: 2002-10-16 Member: 1510Members
    It would help if you showed exactly what you were trying to achieve. From what you say, I'm thinking you have a block of text, with fill-in-the-blanks areas which you would fill depending on the variables passed through the url?

    If so, you will need to gather your vars from the url manually as globals are off by default. The GET vars are now passed into the array $_GET

    So, for example, say you had a var called "name" which you wanted to use. You would give the url:
    www.yoursite.com/yourpage.php?name=yourname

    Then, in your script, pass "name" to a variable (You can use it straight from the array, I just prefer to set them up on thier own) and drop it into your text:

    <!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
    <?php
    $name = $_GET['name'];
    echo 'Welcome to my web page ';
    echo $name;
    echo ', please enjoy your stay';
    ?>
    <!--c2--></td></tr></table><div class='postcolor'><!--ec2-->

    So, if you used Curve as the name, you would get

    <!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->Welcome to my web page Curve, please enjoy your stay<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->

    If you are wanting to pass more than one var through the url, you need to use the & symbol to seperate them, so for name an email, you might use:

    www.yoursite.com/yourpage.php?name=yourname&email=youremail

    That should get you started
  • DOOManiacDOOManiac Worst. Critic. Ever. Join Date: 2002-04-17 Member: 462Members, NS1 Playtester
    And remember kids, <span style='font-family:Courier'>addslashes()</span> is your friend if you're going to be inserting into a database, which you most likely will.
  • twoflowtwoflow Singing Drunk Join Date: 2002-11-01 Member: 1950Members, Constellation
    <!--QuoteBegin-DOOManiac+Apr 25 2005, 11:01 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (DOOManiac @ Apr 25 2005, 11:01 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> And remember kids, <span style='font-family:Courier'>addslashes()</span> is your friend if you're going to be inserting into a database, which you most likely will. <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd-->
    Isn't that covered by things like magic quotes?
  • DOOManiacDOOManiac Worst. Critic. Ever. Join Date: 2002-04-17 Member: 462Members, NS1 Playtester
    Yes, if you use magic quotes.
Sign In or Register to comment.