0

I'm making a simple registration form for a test website and for some reason it isn't sending the data to the database, and I don't get an visual error. I've searched around for a fix but haven't found any that work.

This is basically my form (I only copied the form part of the page):

    <form action="includes/insert.php" method="post">
        <h3>Username</h3>
        <input type="text" name="username">
        <br>
        <br>
        <h3>Email Address</h3>
        <input type="email" name="email">
        <br>
        <br>
        <h3>Password</h3>
        <input type="password" name="password">
        <br>
        <br>
        <br>
        <input id="submit-btn" type="submit" name="submit" value="Submit">
    </form>

As you can see everything is as its suppose to be.

and this is my insert.php

<?
define('DB_NAME', 'logindb');
define('DB_USER', 'root');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db(DB_NAME, $link);

if (!$db_selected) {
    die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}

$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];

$sql = "INSERT INTO `users` (`id`, `username`, `email`, `password`, `timestamp`) VALUES (NULL, '$username', '$email', '$password', CURRENT_TIMESTAMP)";

if (!mysql_query($sql)) {
    die('Error: ' . mysql_error());
}

mysql_close();
?>
17

2 Answers 2

1

Opening PHP tag is

<?php 

Recent versions of PHP do not enable the short code syntax by default.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, i forgot about that :)
0

Use NOW() instead of CURRENT_TIMESTAMP.

2 Comments

Is NOW() more preferable than CURRENT_TIMESTAMP?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.