transferring form data to mysql

Discussion in 'General Discussion' started by Doug_McDougal, Mar 18, 2015.

  1. Doug_McDougal

    Doug_McDougal Bit Poster

    Messages:
    1
    I am new to mysql. I want to transfer data from a form to mysql database. I have tried many different methods, and none seem to work. Here are my two sets of code:

    longin.php page:

    <?php
    $mysqli = new mysqli("localhost", "douglas", "***********", "admin_");
    if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
    }
    echo $mysqli->host_info . "\n";

    $mysqli = new mysqli("127.0.0.1", "douglas", "***********", "admin_", 3306);
    if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
    }

    echo $mysqli->host_info . "\n";
    ?>

    //the above page appears to work properly.

    -------------------------------------------------------------------

    contact.php page:

    <?php
    if (isset($_POST['submitted'])) {
    include('login.php');
    $fname = $_POST['First_Name'];
    $lname = $_POST['Last_Name'];
    $email = $_POST['Email'];
    $category = $_POST['Category'];
    $subject = $_POST['subject'];
    $message = $_POST['Message'];
    $yes = $_POST['Yes'];
    $sql = "INSERT INTO 'Newsletter' (First_Name,Last_Name, Email, Category, subject, Message, Yes) VALUES ('$fname', '$lname','$email', '$category', '$subject', '$message', '$yes');";

    if (!mysqli_query($sql)) {
    die('error inserting new record');
    }//end of nested if statement
    }//end of main if statement
    ?>

    ------------------------------------------
    The above does not retrieve the data from the form. Can anyone help me with this? "Newsletter" is the name of the table, "admin_" is the name of the database, "First_Name,Last_Name, etc" are the fields in the table, 'First_Name','Last_Name',etc are the fields in the form.

    Best,

    Doug McDougal
     
  2. KonstantinB

    KonstantinB Odin Team

    Messages:
    68
    Hi Doug,

    What Parallels/Odin product are you talking about?
     
  3. namquanco

    namquanco Bit Poster

    Messages:
    1

Share This Page