SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    uk
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question php form create unique url user id

    hi,
    how do i create a form, when i fill the form,
    for example to get information of user and name.
    i will go to a user page that the url something like this

    http://......./user.php?=mark (if the user is mark)

    in this page will show, (my name is mark).

    and i can write the data of the form in text file.
    the data that write in the text file is user and name.


    is it i want to use GET methode or POST methode or both.

    thanks in advance.

  2. #2
    SitePoint Member
    Join Date
    Aug 2004
    Location
    mishawaka, in
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    get

    method=get puts the form variables in the query string.

    Code:
    <form action="action/you/want.php" method="get" name="formname">
    
    </form>

  3. #3
    SitePoint Member
    Join Date
    Sep 2004
    Location
    uk
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how about i want to take another variable like name?

    and the submit button?


    all the variable come out in the url link, but i just want the username come out?

  4. #4
    SitePoint Member
    Join Date
    Aug 2004
    Location
    mishawaka, in
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can keep the method of the form equal to post, but just put the name in the query string of the action. Example:

    Code:
    //get user info
    $sql = "SELECT * FROM users WHERE userdID = '1' LIMIT 1";
    $result = mysql_query($sql) or die(mysql_error());
    $row = msyql_fetch_assoc($result);
    
    
    <form action = "<?php echo $_SERVER[PHP_SELF] . '?username=' . $row[username];?>" method="post" name="formname">
    
    <!-- form inputs and such go here-->
    
    </form>
    This will make the query string look like:
    http://www.domainname.com/filename.php?username=mark

    To access username just use $_GET[username]. To access the other variables use $_POST[whatever_variable].


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
  •