Jump to content

No data captured after submission of the form


genzedu777

Recommended Posts

Hi guys,

 

I need some help in my coding, I have submitted the form, and basically I should see the success msg, which is echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>'. However it wasnt appearing, and when I look into my database, I couldnt find any record which I have registered, is there something amiss in my coding? Please help, Thanks

 

 

<?php

  require_once('123.php');

 

  // Connect to the database

  $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)

  or die(mysql_error());

 

  if (isset($_POST['submit'])) {

    // Grab the profile data from the POST

    $name = $_POST['name'];

$email = $_POST['email'];

    $password = $_POST['password'];

$location = $_POST['location'];

$dob = $_POST['dob'];

$category = $_POST['category'];

 

        $query = "INSERT INTO practice_user (name, email, password, location, dob, category, join_date) " .

"VALUES ('$name, $email', $password, $location, $dob, $category, NOW())";

        mysqli_query($dbc, $query)

or die(mysql_error());

 

        // Confirm success with the user

        echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>';

 

        mysqli_close($dbc);

}

?>

Your query is poorly formed, you should be getting an error.

 

Your query should be....

 

$query = "INSERT INTO practice_user (name, email, `password`, location, dob, category, join_date) VALUES ('$name', '$email', '$password', '$location', '$dob', '$category', NOW())";

 

Make sure you also escape any user inputed data using mysqli_real_escape_string.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.