I have been working on the form to database for sometime now, ofcourse I am a student and things are not working as desired. However, I have made some progress. I have a form page that gathers member info Firstname, Lastname, State, Email, username, passoword and verfiy password. The page is account.php.
That info is sent to login.php and gathers the info into variables, connects to server (localhost). To make sure the information is getting passed I echo the Firstname to the page and it prints fine, the problem is this, it does not insert info into the database. I also have the database echo the results to the page for now to see if the info is entering the database, which it is not. It does create the ID number (auto_increment) and the column names, but no member info. Before I wasn’t even getting that, so I have made some improvement.
Below is what I have to connect, gather and insert member info. Could you please review and advise why information is not inserting into the database.
NOTE: Member names, state and email is set to one table and username, password and verfiy password to another.
[code]
<?php $mysqli = mysqli_connect("localhost", "walter", "******", "db_family_members"); if (mysqli_connect_errno()) { printf("Connect failed: %sn", mysqli_connect_error()); exit(); } if ($mysqli) { $first = empty($_POST['FirstName']) ? die ("ERROR: Enter First Name") : mysqli_connect_error($_POST['FirstName']); $last = empty($_POST['LastName']) ? die ("ERROR: Enter Last Name") : mysqli_connect_error($_POST['LastName']); $state = empty($_POST['ST']) ? die ("ERROR: Enter your State") : mysqli_connect_error($_POST['ST']); $email = empty($_POST['EmailAdd']) ? die ("ERROR: Enter your State") : mysqli_connect_error($_POST['EmailAdd']); $query = "INSERT INTO tbl_member_info VALUES (NULL, '".$first."', '".$last."', '".$state."', '".$email."')"; mysqli_query($mysqli, $query); } if ($mysqli) { $user = empty($_POST['Username']) ? die ("ERROR: Enter Username") : mysqli_connect_error($_POST['Username']); $pass = empty($_POST['Password']) ? die ("ERROR: Enter Password") : mysqli_connect_error($_POST['Password']); $vpass = empty($_POST['VPassword']) ? die ("ERROR: Verify Password") : mysqli_connect_error($_POST['VPassword']); $query = "INSERT INTO tbl_users VALUES (NULL, '".$user."', '".$pass."', '".$vpass."')"; mysqli_query($mysqli, $query); } if ($mysqli) { $result = $mysqli->query("SELECT * FROM tbl_member_info"); while($row = $result->fetch_array()) { foreach($row as $key => $value){ echo "$key = $valuen"; } } } $result->close(); $mysqli->close(); ?>[/code]
MOD EDIT: Added code tags, removed password