adam291086 0 Junior Poster in Training

I have a third party sending me some infomaion. They say to use php $_post to recieve the information as follows

<?php
//include the database handling class
  include("mysqlclass.php");
    
  //Assign POSTED variables
  $destination = $_POST['gwNumber'];
  $originator = $_POST['originator'];
  $message = $_POST['message'];
  $smsTime = $_POST['smsTime'];
  $timeZone = $_POST['timeZone'];
  $network = $_POST['network'];
  $id = $_POST['id'];
  $status = $_POST['status'];

  //Create a new instance of the mysql class and write data to database
    $mysql = New mysql(0);

    $sql = "
      INSERT INTO
        virtual
          (varOriginator, varDestination, varMessage, varTime, intTimeZone, varNetwork, intId)
     VALUES
          ('$originator', '$destination', '$message', '$smstime', '$timeZone', '$network', '$id')";

    $mysql->query($sql);
?>

now i want to do this with python and have come up with

#!/usr/bin/python
import MySQLdb
import cgi
print "Content-type: text/html\n"
# connect
db = MySQLdb.connect(host = "localhost", user = "dfgdfgdfgdgfdfgdfgdfg passwd = "Udfgfdgdfgdfgdfdfgfdggsgsf", db = "adamplo1_UniProject")
# create a database cursor
cursor = db.cursor(MySQLdb.cursors.DictCursor)

#execute SQL select statement

form = cgi.FieldStorage()

destination = "sdfsdfsdf"
originator = "sdfsdfsdf"
message =  form["message"]
smsTime = "sdfsdfsdf"
timeZone = "11"
network = "sdfsdfsdf"
ID = "1"
status = "sdfsdfsdf"

sql = "INSERT INTO virtual (varOriginator, varDestination, varMessage, varTime, intTimeZone, varNetwork, intId) VALUES ('"+originator+"', '"+destination+"', '"+message+"', '"+smsTime+"', '"+timeZone+"', '"+network+"', '"+ID+"')"
print sql
print cursor.execute(sql)

But nothing is being update. Is there another way to get the POST data?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.