Results 1 to 4 of 4

Thread: manage page with php

  1. #1
    Join Date
    Jul 2010
    Location
    NangYang
    Posts
    20
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default manage page with php

    Hello,
    I am new to PHP.
    I am building my own forum by php.
    I have a little problem that I want to manage pages or posts for it. That means when an user wants to write a new post in different subjects but I want to link to 1 file for example post.php, I dont know how to differentiate them.
    I have read some guides that follow post.php is somethings like post.php?action=.... . But I still dont understand the things after .php?..
    Can someone tell me about this? because idk it is just 1 file post.php but different action or they are different.
    Can someone tell me details about what follow that or give me a link that I can read. This maybe simple but actually I dont understand.
    Thank you so much.

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    It is one page with different actions, or get requests.

    http://php.net/manual/en/reserved.variables.get.php

    Basically anything after ? is the variable name, anything after the = is what thait variable contains if you want two variables use &.

    So http://site.com/this.php?a=1&b=2

    and to call those

    Code:
    $a = $_GET['a'];
    $b = $_GET['b'];
    echo "a= $a <br /> b = $b";
    This should output:
    a=1
    b=2

    unless I typed something wrong you also may want to use isset (http://php.net/manual/en/function.isset.php) so you aren't calling variables that have been set/used.
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Also, in the bigger picture, then all you need to do is add "if" statements checking the information in the previous post, and do the action that matches what was sent.

    One way to use a single form to do multiple actions (aside from checking exactly what data was sent, which is also possible) is to use two different submit buttons named the same thing:
    <input type="submit" name="mysubmit" value="next">
    <input type="submit" name="mysubmit" value="previous">

    Then check $_POST['mysubmit'] to see if it was "next" or "previous" (or anything else you want) and decide what to do.

    Note that post and get work the same way: $_GET/$_POST, <form method="get"> OR <form method="post">. If you use "get", then the info will appear in the URL and you can also just use regular links for this. If you use "post" it will be hidden (sent separately from the URL) and is more common with things that are only for forms because you can't use it by just typing a new URL.


    In general, your question is very broad, so once you know a little more about your plans please post back with some code or more details about the specific parts that are confusing and we'll try to help. But at the moment I think you'd do well just reading some introductory tutorials for PHP because most of this is part of what PHP is very often used for.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Jul 2010
    Location
    NangYang
    Posts
    20
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Thanks alot for giving help, now I understood .
    I am reading a book and try to practice it on my website.
    I will read and search carefully before posting questions. Just now this problem I didn't know how to search, tried some but no results.

    Thank you for usefull information.

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
  •