inserting values from python into mysql
Hi guys i have a problem with my coding which i need help in.
i need to insert data from the form eg first name, last name, password etc into mysql:
<TR>
<TD><span>First name <font color="red">*</font></span></TD>
<TD><input type="text" class="text" maxlength="32" name="first_name"
value=""/></TD
</TR>
<TR>
<TD><span>Last name <font color="red">*</font></span></TD>
<TD><input type="text" class="text" maxlength="32" name="last_name"
value=""/></TD>
</TR>
so now im trying to get these values and store it into mysql user table.
>>db = MySQLdb.connect("123.12.3.12", "asda",
"helloworld", "qwerty", 3306)
>>c = db.cursor ()
>>sql = ("INSERT INTO user (first_name, last_name, gender, birth_year,
quote, user_name, user_password) VALUES (%s, %s, %s, %s, %s, %s, %s)");
>>"Account created for", user_name
>>sys.exit(1)
>>c.execute(sql)
>>c.close ()
>>db.commit()
>>db.close ()
>><html>
>><p>Please login <a href='home.py'><b>here</b></a>.</p>
>></html>
is this code right concerned with connecting python and mysql, inserting the values?