Hey, I have a problem with a script that runs on my registration page of my website. The index page contains a submit button which links the user to the registration page, however, since updating the code to include more fields I get this error:
'Failed to run query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'username' cannot be null'
I get this error just by clicking a link to the register.php page, so I figure something in my registration php code is submitting data as soon as the button is clicked on the index page, which shouldn't be happening. I'd paste all my code, but there is a lot. So I'll paste the seemingly important bits, and if you want more let me know.
register.php
index.html
I want to know which part of my code is causing the error (it actually used to work until I extended the database and so extended the PHP) & I'll be honest I have no idea where to start looking in my PHP code.
p.s. I know that using 'die' isn't the best method
'Failed to run query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'username' cannot be null'
I get this error just by clicking a link to the register.php page, so I figure something in my registration php code is submitting data as soon as the button is clicked on the index page, which shouldn't be happening. I'd paste all my code, but there is a lot. So I'll paste the seemingly important bits, and if you want more let me know.
register.php
<?php
include 'common.php';
if(!empty($_POST))
{
// Ensure that the user has entered a non-empty username
if(empty($_POST['username']))
{
die("Please enter a username.");
}
...
index.html
<input type="submit" class="registration" value="Register" /> </form>
I want to know which part of my code is causing the error (it actually used to work until I extended the database and so extended the PHP) & I'll be honest I have no idea where to start looking in my PHP code.
p.s. I know that using 'die' isn't the best method