Hold value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Garry Jones

    Hold value

    I have a web form to collect player data from team leaders.

    Problem 1

    Each team leader may enter individual data for any ammount of others. Each
    time the form is submitted I am clearing the field which also clears the
    team leader's name. What I want is a way of holding the initial field (team
    leaders name) whilst in session. I think I can do this with a php variable.
    Cant quite grasp the syntax

    Problem 2
    On submit I intend sending the data to my email address and to a mysql
    database. Whats a simple way for me to get the mysql database to email me a
    csv file from the database? Can I do this with PHP code from the website

    Garry Jones
    Sweden






  • Erwin Moller

    #2
    Re: Hold value

    Garry Jones wrote:
    [color=blue]
    > I have a web form to collect player data from team leaders.[/color]

    Hi Garry,
    [color=blue]
    >
    > Problem 1
    >
    > Each team leader may enter individual data for any ammount of others. Each
    > time the form is submitted I am clearing the field which also clears the
    > team leader's name. What I want is a way of holding the initial field
    > (team leaders name) whilst in session. I think I can do this with a php
    > variable. Cant quite grasp the syntax[/color]

    From the receiving script (= the script named in the action of the form) you
    can retrieve a POST value as follows:
    $teamname = $_POST["teamname"];

    If you want to 'recyle' that name, just give it as a value to the
    corresponding formfield:
    <input type="text" name="teamname" value="<?= $teamname ?>">

    If you need to pass around a variable from script to next script, you can
    use a session.

    It is all here:


    In short:
    - put a variable in a session:
    $_SESSION["teamname"] = $teamname;

    from another script:
    $_SESSION["teamname"] now contains the value you put into it.
    [color=blue]
    >
    > Problem 2
    > On submit I intend sending the data to my email address and to a mysql
    > database. Whats a simple way for me to get the mysql database to email me
    > a csv file from the database? Can I do this with PHP code from the website[/color]

    That are two different thing.
    I suggest that your receiving script first does a database insert, and then
    mails the results (as csv or whatever suits you) to your mainadress.
    Look up at www.php.net the mail function.

    Regards,
    Erwin Moller
    [color=blue]
    >
    > Garry Jones
    > Sweden[/color]

    Comment

    • fletch

      #3
      Re: Hold value

      > Problem 2[color=blue]
      > On submit I intend sending the data to my email address and to a mysql
      > database. Whats a simple way for me to get the mysql database to email me
      > a csv file from the database? Can I do this with PHP code from the website[/color]

      This is reasonably straightforward code. I would suggest that you could
      same time by installing phpMyAdmin and have that produce the csv.

      Comment

      Working...