Jump to content

Database returning 'NULL' values when submitting data from form HELP!!


benjamin_boothe

Recommended Posts

[code]
if ($msg=="") {
    $insert = "INSERT INTO policy_holder
    ( id, title, first_name, surname, date_of_birth, uk_residency, marital_status,
    disability, employment_status, address_line_1, area, town, county, post_code,
    telephone_work, telephone_home, fax_number, email)
    VALUES ( NULL, '$t', '$fn', '$sn', '$dob', '$uk', '$ms', '$d', '$es', '$ad1', '$a',
    '$tn', '$c', '$pc', '$tw', '$th', '$fax', '$em')";
[/code]

That is the query I am running.  I echoed it to see what it is doing:

[quote]
INSERT INTO policy_holder ( id, title, first_name, surname, date_of_birth, uk_residency, marital_status, disability, employment_status, address_line_1, area, town, county, post_code, telephone_work, telephone_home, fax_number, email) VALUES ( NULL, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')
[/quote]

It's not returning the values in the db that I am putting into my form.
Link to comment
Share on other sites

Because the globals are off I had to use this piece of code.  This was because at first, I was getting 'Notice: Undefined' messages.  So I had to declare all of my variables like this:

[code]
$t = isSet($_POST['title']) ? $_POST['title'] : '';
$fn = isSet($_POST['first_name']) ? $_POST['first_name'] : '';
$sn = isSet($_POST['surname']) ? $_POST['surname'] : '';
$dob = isSet($_POST['date_of_birth']) ? $_POST['date_of_birth'] : '';
$uk = isSet($_POST['uk_residency']) ? $_POST['uk_residency'] : '';
$ms = isSet($_POST['marital_status']) ? $_POST['marital_status'] : '';
$d = isSet($_POST['disability']) ? $_POST['disability'] : '';
$es = isSet($_POST['employment_status']) ? $_POST['employment_status'] : '';
$ad1 = isSet($_POST['address_line_1']) ? $_POST['address_line_1'] : '';
$a = isSet($_POST['area']) ? $_POST['area'] : '';
$tn = isSet($_POST['town']) ? $_POST['town'] : '';
$c = isSet($_POST['county']) ? $_POST['county'] : '';
$pc = isSet($_POST['post_code']) ? $_POST['post_code'] : '';
$tw = isSet($_POST['telephone_work']) ? $_POST['telephone_work'] : '';
$th = isSet($_POST['telephone_home']) ? $_POST['telephone_home'] : '';
$fax = isSet($_POST['fax_number']) ? $_POST['fax_number'] : '';
$em = isSet($_POST['email']) ? $_POST['email'] : '';
[/code]

Beforehand I was declaring the variable like this:

For example, if wanted to declare the 'fax_number' form variable, I was doing this:


[code]$fax = isSet($_POST['fax']) ? $_POST['fax'] : '';[/code]


Which was why it was not reading the values that I was inputting, as I was not making the field names (form inputs) equal to the variables like this:

[code]$fax = isSet($_POST['fax_number']) ? $_POST['fax_number'] : '';[/code]

That was the issue all along!!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.