#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    1
    Rep Power
    0

    mod_python, PSP help...


    Hi,

    Ive been looking everywhere to try to get POST variables to work,
    I manage to send them and receive them with req.read, but I get the whole bunch of them. How can I put each post var in a python var.

    Is there something like the $_POST methods in php ? I could really use some help as you can see Im new at Python


    Thanks in advance.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Atlantic City, NJ
    Posts
    327
    Rep Power
    13
    Code:
    <input name="first_name" />
    <input value="Search" type="submit" />
    The 'form' method will take all post data and put it into a dictionary. So to get what is typed in the "first_name" box you can do:

    Code:
    <%
    form["first_name"].value
    %>
    or to see if anything is in there you can do:

    Code:
    <%
    if form.has_key("first_name"):
           do something...
    %>
    Again, all the dictionary methods apply because calling form gobbles up all the form data into a dictionary.
    Last edited by Shiner_Man; June 7th, 2005 at 06:18 AM.
    I'll learn this stuff someday.

IMN logo majestic logo threadwatch logo seochat tools logo