Insert data into MySQL from HTML Form using .psp script

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

    Insert data into MySQL from HTML Form using .psp script

    I am attempting to insert data from a HTML form using a .psp script.
    I can not find how to link the data that is inserted into the form to
    the variables in the .psp script to then insert into the MySQL Insert
    statement. I am familiar with PHP, where you would write
    $_POST(['field']), however I can not find the equivalent in PSP. I
    believe that this is the my missing piece. Technically, what is
    occurring that that when I click the 'Submit' button, it is inserting
    NULL field values into the db.

    Sample code is below ::

    HTML FORM CODE

    <html>
    <head>
    <link rel="stylesheet " type="text/css" href="./styles/
    projectpage.css ">
    </head>

    <h2>PAGE</h2>
    <form name="input_for m" action="insert_ go.psp" method="post">
    Date:
    <input type="text" name="date" id="date">
    <br>
    Time:
    <input type="text" name="time" id="time">
    <br>
    Activity:
    <input type="textarea" rows="20" cols="40" name="activity"
    id="activity">
    <br>
    Next Steps:
    <input type="textarea" rows="20" cols="40" name="notes" id="notes">
    <br>
    <input type="submit" value="Submit">
    </form>
    </html>

    Below is the psp script

    <%
    import MySQLdb

    host = 'localhost'
    user = 'user'
    passwd = 'somepass'
    db = 'MyDB'

    conn = MySQLdb.connect (host, user, passwd, db)
    mysql = conn.cursor()

    sql = ("""INSERT INTO activity VALUES (date,time,acti vity,notes);""" );

    mysql.execute(s ql)

    conn.commit()
    mysql.close()
    conn.close()
    %>

    <html>
    <p>Sucess!</p>
    </html>

    Thanks for any assistance.

    B
Working...