MySQL Forums
Forum List  »  PHP

Data not being entered into database
Posted by: Gordon White
Date: March 13, 2016 08:51AM

I have a data entry form that seems to work OK.
I have a process.php that grabs the correct data, but does not insert it into the database.

Can someone please direct me to the problem and a fix?


Here is the data form (This works fine, it's here for your review):

<?php

include "config.php";

$result = $conn->query("select playersid, name from players");
$result1 = $conn->query("select dateid, week from dates");

echo "<html>";
echo "<head>";
echo " <style>";

echo "p.pos_right {";
echo " position: relative;";
echo " left: 300px;";
echo " top: 100px;";
echo "}";

echo "h3.pos_right {";
echo " position: relative;";
echo " left: 300px;";
echo " top: 100px;";
echo "}";

echo "</style>";
echo "</head>";

echo "<body bgcolor='Black'>";



echo '<form name="htmlform" method="post" action="process.php">';

echo "<h3 class='pos_right'><font color='White'>Enter This Weeks Information</h3>";

echo '<p class="pos_right">';

echo "<font color='White'>Select Player - ";
echo "<select name='players'>";
while ($row = $result->fetch_assoc()) {
unset($playersid, $name);
$playersid = $row['playersid'];
$name = $row['name'];
echo '<option value="'.$playersid.'">'.$name.'</option>';
}
echo "$playersid";
echo "</select>";
echo "<p></p>";

echo '<p class="pos_right">';

echo "<font color='White'>Select Date - ";
echo "<select name='date'>";

while ($row = $result1->fetch_assoc()) {
unset($dateid, $week);
$dateid = $row['dateid'];
$week = $row['week'];
echo '<option value="'.$dateid.'">'.$week.'</option>';
}

echo "</select>";
echo "<p></p>";

echo '<p class="pos_right">';

echo "<p<font color='White'>Did Player Attend? - <INPUT TYPE=radio NAME='attend' VALUE='1'></p>";

echo '<p class="pos_right">';

echo "<font color='White'>Select Number of Points Earned - ";
echo '<select name="points">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>';
echo "<p></p>";

echo '<p class="pos_right">';
echo "<font color='White'>Amount Received - $ <input type 'text' name='payout' maxlength='4'><br><br>";

echo "<font color='White'>High Hand Amount - $ <input type 'text' name='hh' maxlength='4'><br><br>";

echo "<font color='White'>50/50 Amount - $ <input type 'text' name='ff' maxlength='4'><br><br>";

echo '<font color="White"><input type="submit" value="Submit">';

echo "</body>";
echo "</html>";
?>


Here is the process.php script (This is the problem area):
<?php

//Database Connection

include "config.php";

//Grab info from form
$player = $_POST['players'];
$date = $_POST['date'];
$att = $_POST['attend'];
$pts = $_POST['points'];
$amt = $_POST['payout'];
$high = $_POST['hh'];
$fty = $_POST['ff'];

//Insert into database
$sql = "INSERT INTO data (playersid, dateid, attend, points, payout, hh, ff) VALUES ('$player', '$date', '$att', '$pts', '$amt', '$high', '$fty')";

mysql_query($sql);

//close Connection
mysql_close($conn);

//Display information from form
//THIS WORKS CORRECTLY
print "<HTML><TITLE> Data Entry Results </TITLE><BODY
BGCOLOR=\"#FFFFFF\"><center><table border=\"0\"
width=\"500\"><tr><td>";

print "<p><font face=\"verdana\" size=\"+0\"> <center>You
Just Entered This Information Into the
Database<p><blockquote>";

print "Players ID : $player<p>Date ID :
$date<p>Attend : $att<p>Points : $pts<p>Prize Amount : $amt<p>High Hand : $high<p>50/50 : $fty<p></blockquote></td></tr></table>
</center></BODY></HTML>";
?>

Options: ReplyQuote


Subject
Written By
Posted
Data not being entered into database
March 13, 2016 08:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.