I am a super noob with PHP and MySQL, my experience is HTML and CSS but I am trying to improve my skillset and have begun a small project to learn the ropes of PHP and MySQL. I'm not familiar with much of the terminology yet so apologize if this post is in any way unclear.
In my project I am currently trying to get user information Inserted into a MySQL database I created. I have had most of the fields being input correctly until tonight when I added 3 File Upload fields. These 3 fields are working from my form to my database (ie filenmes are being inserted properly), but now my telephone form field input is not being inserted correctly. The data echos as expected, but is written to the data base as a different phone number each time. The different value is the same each time, but NOT what is input into the form. I am assuming I have a value stated explicitly somewhere, but can not find it. Also, when I echo the php variable $phone, the correct user-input value is shown. It's driving me crazy b/c it is probably something silly I am overlooking.
Here is my code for the php form file:
if (isset($_POST['register_submit'])) {
// Variables
$first_name = $_POST['register_firstname'];
$last_name = $_POST['register_lastname'];
$gameranger = $_POST['register_gameranger'];
$email = $_POST['register_email'];
$password = $_POST['register_password'];
$password_confirm = $_POST['register_password_confirm'];
$phone = $_POST['register_phone'];
$civ = $_POST['register_civ'];
$map = $_POST['register_map'];
$color = $_POST['register_color'];
$motto = $_POST['register_motto'];
$crest = $_FILES['register_crest'] ['name'];
$player_image = $_FILES['register_image'] ['name'];
$sound = $_FILES['register_sound'] ['name'];
$rules = $_POST['register_rules'];
$output_form = false;
// Validation checks here
if ((!empty($first_name)) && (!empty($last_name)) && (!empty($gameranger)) && (!empty($email)) && (!empty($password)) && (!empty($password_confirm)) && (!empty($phone)) && (!empty($civ)) && (!empty($map)) && (!empty($color)) && (!empty($motto)) && (!empty($rules))) {
// Connect to database and insert player information
$dbc = mysqli_connect('localhost', 'yourpass', 'Colin$2009', 'yourpass_aoe')
or die('Could not connect to database.');
$query = "INSERT INTO players (first_name, last_name, gameranger, email, phone, password, civ, color, map, motto, crest, sound, accept_rules, player_image)" .
"VALUES ('$first_name', '$last_name', '$gameranger', '$email', '$phone', SHA('$password'), '$civ', '$color', '$map', '$motto', '$crest', '$sound', '$rules', '$player_image')";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
mysqli_close($dbc);
}
}
else {
$output_form = true;
}
if ($output_form) {
<form enctype="multipart/form-data" id="register" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" /> <!-- Max file size = 2 megs -->
<fieldset>
<ul>
<li class="required">
<label for="register_firstname">First Name:</label>
<input type="text" class="text" name="register_firstname" id="register_firstname" value="<?php echo $first_name ?>" />
<strong>Required</strong>
<!-- rest of form here -->
<li class="required">
<label for="register_phone">Phone:</label>
<input type="text" class="text" name="register_phone" id="register_phone" value="<?php echo $phone ?>" />
<strong>Required</strong>
</li>
else {
echo '<p>Welcome to the AOE Tournament of Conquerors, Lord ' . $last_name . '. You must be a brave and noble sovereign indeed to lead the mighty ' . $color . ' armies of the ' . $civ . ' into battle against your enemies across the lands of the ' . $map . '.</p>';
echo '<p>Should your opponents need to send you their intent to do battle tthey will do so either by sending emissaries to your castle\'s address or a messenger pigeon to your Chancellor at ' . $phone . '. You are bound by tournament rules to peacefully accept these emissaries and respond in kind.</p>';
echo '<p>To enter the tournament grounds, you will need to provide the guards at the gate of the King\'s Castle with your castle\'s address and password. We have recorded your castle\'s address as <strong>' . $email . '</strong> and your password as <strong>' . $password . '</strong>.</p>';
echo '<p>As King of Niagara Thistle and the promoter of this Tournament of Conquerors, I wish you and your brave armies good luck and Godspeed!</p>';
echo '<p>As they say in your lands: ' . $motto . '!</p>';
echo '<div class="content"><a class="button" href="user_profile.php" rel="" title="Continue to your Lord\'s chambers.">Enter Tournament</a></div>';
}
Any help in figuring out why the User Phone number echos correctly in the form and also but is not being inserted correctly into the database would be great. Again, a specific 10-digit number IS being inserted each time I create a user and is the same each time, but it is NOT the user input value.