Hello guys,

Long story short, when I register a user on my website, it enters for every single column value 0.

It should be due to the fact that's not picking up the data from my registration page? Although, it should be ok as I am only picking up the value....

Any help would appriciated.

<?php
session_start();
error_reporting (E_ALL ^ E_NOTICE);

echo '<head>';

echo ' <link rel="stylesheet" TYPE="text/css" HREF="css/style.css"/>';

echo '</head>';
// for error handling
ini_set('session.bug_compat_42',0);
ini_set('session.bug_compat_warn',0);
error_reporting(-1);
ini_set('display_errors', 'On');
$errorMessage = "";

$ename = $_POST["ename"];
$epass  = $_POST["epass"];
$cpass  = $_POST["cpass"];
$CompanyName = $_POST["CompanyName"];
$CompanyCountry = $_POST["CompanyCountry"];
$CompanyState = $_POST["CompanyState"];
$CompanyZip = $_POST["CompanyZip"];
$CompanyCity = $_POST["CompanyCity"];
$CompanyAddress = $_POST["CompanyAddress"]; 
$CompanyPhone = $_POST["CompanyPhone"];
$CompanyPhone2 = $_POST["CompanyPhone2"]; 
$CompanyEmail = $_POST["CompanyEmail"];




$conn = mysql_connect("localhost", "root", "") or die("cannot connect"); 
mysql_select_db("recruiting") or die (mysql_error());




if ($epass == $cpass) 
{
   if(!empty($ename) && !empty($epass) && !empty($CompanyName) && !empty($CompanyCountry)  && !empty($CompanyZip) && !empty($CompanyCity) && !empty($CompanyAddress) && !empty($CompanyPhone) && !empty($CompanyEmail))
   {
    $q1 = ("INSERT INTO job_employer_info
    (ename, 
    epass,
    CompanyName, 
    CompanyCountry, 
    CompanyState, 
    CompanyZip, 
    CompanyCity, 
    CompanyAddress, 
    CompanyPhone, 
    CompanyPhone2, 
    CompanyEmail)
         VALUES(
         ename = '$ename', 
        epass = '$epass',
        CompanyName = '$CompanyName', 
        CompanyCountry = '$CompanyCountry', 
        CompanyState = '$CompanyState',
        CompanyZip = '$CompanyZip', 
        CompanyCity = '$CompanyCity', 
        CompanyAddress = '$CompanyAddress', 
        CompanyPhone = '$CompanyPhone', 
        CompanyPhone2 = '$CompanyPhone2', 
        CompanyEmail = '$CompanyEmail')");


    $r1 = mysql_query($q1);

if($r1 == FALSE)
{
    echo "ERROR - No mactching rows from th database!<br/>";
}
else
{


    // Redirect to the main menu
    header ("Location: index.html");

}


//$to = $CompanyEmail;
//$subject = "Your account at yourdomain.com";
//$message = "This is your account information at yourdomain.com\n\n username: $ename\n password: $epass\n\n\n Keep this information in a secure place. \n\n Thanks for your registration. We believe you will find the staff you need at  http://yourdomain.com ";
//$from = "From: <youremail@youremail.com>";

//mail($to, $subject, $message, $from);

   }    
    else{
    echo "<center><font color=red><b> You didn't fill some of the required fields.<br>Go back and fill them correctly, please.</b></font></canter>";
    }
}
else
{
    echo "<center><br><br><br><font color=red><b> You have a mistake filling the password/confirm password fields. <br> Go <a class=ERR href=employer_registration.php> back </a> and fill all them  properly, please.</b></font></center>";
}





 mysql_close($conn);
?>

Your insert query syntax is a bit strange. The basic syntax would be:

INSERT INTO tablename (field1, field2,...) VALUES (value1, value2, ...)

so in your case

 $q1 = "INSERT INTO job_employer_info
(ename,
epass,
CompanyName,
CompanyCountry,
CompanyState,
CompanyZip,
CompanyCity,
CompanyAddress,
CompanyPhone,
CompanyPhone2,
CompanyEmail)
VALUES(
'$ename',
'$epass',
'$CompanyName',
'$CompanyCountry',
'$CompanyState',
'$CompanyZip',
'$CompanyCity',
'$CompanyAddress',
'$CompanyPhone',
'$CompanyPhone2',
'$CompanyEmail')";

You sir, have resolved it. Thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.