Note: this project is being restarted after one year of in-action, using the most relevant files I am able to locate. All final code will be adapted to MySQLi.

Versions of this code functioned properly to the best of my knowlege; now, with a new host I am having issues saving data to the db after a connection is made.

I have been researching the potential issue online but would like some advice regarding possible problems/errors regarding this issue before I proceed with editing the files.

Thank you in advance,
Matty

snippet of index.html
`

<?php

function NewUser()
{  
    $userName = $_POST['user'];
    $email = $_POST['email'];
    $password =  $_POST['pass'];
    $countries = $_POST['countries'];
    $state = $_POST ['state'];
    $city =  $_POST['city'];
    $company = $_POST ['company'];
    $manager1 =  $_POST['manager1'];
    $manager2 =  $_POST['manager2'];

    $query = "INSERT INTO X1 Table 1 (userName,email,password,countries,state,city,company,manager1,manager2) VALUES ('$userName','$email','$password','$countries','$state','$city','$company','$manager1','$manager2')";
    $data = mysql_query ($query)or die(mysql_error());
    if($data)
    {
    echo $state
    //echo "YOUR REGISTRATION IS COMPLETED...";
    }
}

function SignUp()
{
    if(!empty($_POST['userName']))   //checking the 'user' name which is from Sign-Up.html, is it empty or have some text
    {
        if ($_POST['equals_val'] != ($_POST['first_val'] + $_POST['second_val'])) {
            echo "CAPTCHA IS NOT CORRECT";
        } else {
            $query = mysql_query("SELECT * FROM X1 WHERE userName = '$_POST[userName]' AND pass = '$_POST[password]'") or die(mysql_error());

            if(!$row = mysql_fetch_array($query) or die(mysql_error()))
            {
                NewUser();
            }
            else
            {
                echo "SORRY...YOU ARE ALREADY REGISTERED USER...";
            }
        }
    }
}
if(isset($_POST['submit']))
{
    SignUp();
}
if (isset($_POST['type'])) {
    if ($_POST['type'] == "login") 

}
?>
Inline Code Example Here

`

connect.php
`

<?php

$serverName = "localhost";
$userName = "*****";
$password = "**********"; 
$dbName = "******";

// Create connection
$conn = new mysqli($serverName, $userName, $password, $dbName); 

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Prepare and bind

    $userName = $_POST['user'];
    $email = $_POST['email'];
    $password =  $_POST['pass'];
    $countries = $_POST ['countries'];
    $state = $_POST ['state'];
    $city =  $_POST['city'];
    $company = $_POST ['company'];
    $manager1 = $_POST ['manager1'];
    $manager2 = $_POST ['manager2'];

    echo "Thank you for registering - New records created successfully!"; 

?>

`

Recommended Answers

All 3 Replies

Update:

Now that I am again looking at other versions of the code, I notice some major issues; there are obviously some elements missing in the code I originally posted here and am using. So, please forgive this oversight. It's embarrasing.

This is another result of dealing with multiple versions; one year ago (when shutting this project down, I thought that I was very thorough about backing up all code for future use) Now, I see I was not thorough enough. I had the feeling this would happen.

I am going to edit my code now and will repost with further questions if necessary .

Thanks!

Update:

Upon adjusting the connect.php file, and testing it, I receive the following response:

Access denied for user '#####'@'localhost' (using password: NO)

The code I added was:

`

 $query = "INSERT INTO ######  (userName,email,password,countries,state,city,company,manager1,manager2) 
    VALUES ('$userName','$email','$password','$countries','$state','$city','$company','$manager1','$manager2')";

    $data = mysql_query ($query)or die(mysql_error());
    if($data)
    {
    echo "YOUR REGISTRATION IS COMPLETED...";
    }Inline Code Example Here

`

I am not sure why I am getting this error message. I have a password set and have never seen this before.

How could adding that snippet of code cause this?

Member Avatar for diafol

You seem to be mixing mysqli and mysql. Stick to mysqli. They aren.t the same thing.

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.