php script that displays a form and inserts into mysql database

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

    php script that displays a form and inserts into mysql database

    Hi everyone,

    I am having trouble with this. I would like to combine a html form
    and the php processing into one file and insert the info into mysql.

    So a basic form which gets processed in the same script which also
    inserts inot mysql whats the general syntax for that. does the php go
    at the top or vise versa
  • Andy Hassall

    #2
    Re: php script that displays a form and inserts into mysql database

    On 22 Jan 2005 02:58:44 -0800, robrecc@gmail.c om (Rob) wrote:
    [color=blue]
    >I am having trouble with this. I would like to combine a html form
    >and the php processing into one file and insert the info into mysql.
    >
    >So a basic form which gets processed in the same script which also
    >inserts inot mysql whats the general syntax for that. does the php go
    >at the top or vise versa[/color]

    Well, there's many ways of doing it, but a simple idiom would be something
    like:

    if data received from form then
    validate data
    if data validated then
    update database
    if database update successful
    display success page or redirect elsewhere
    end script
    end if
    end if
    end if

    if validation or database update failed
    display form with data plus any validation errors
    else
    display blank form
    end if

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • DH

      #3
      Re: php script that displays a form and inserts into mysql database

      Rob wrote:[color=blue]
      > Hi everyone,
      >
      > I am having trouble with this. I would like to combine a html form
      > and the php processing into one file and insert the info into mysql.
      >
      > So a basic form which gets processed in the same script which also
      > inserts inot mysql whats the general syntax for that. does the php go
      > at the top or vise versa[/color]

      Have a look at phpMyEdit v5.4

      Creates one script for Add, View, Change, coPy, Delete. Default display
      is a searchable list of records. Numerous configuration options are
      available. Perfect for administrative forms, can be adapted for publicly
      available forms with a little effort.

      Comment

      Working...