srhino Posted November 28, 2007 Share Posted November 28, 2007 Still trying to understand PHP fully. I am having a problem inserting values from a form into the database. I can't figure out where I am going wrong. I have and admin sheet where I click on the word doubles and it takes me to newdouble which is a form that passes to adddouble. here is the code: newdouble.inc.php <?php $schoolid=$_GET['id']; echo "<form action=\"index.php\" method=\"post\">\n"; echo "<h2>ENTER DOUBLES SCORES</H2>"; echo "SCHOOL<input type=\"text\" name=\"name\">\n"; echo "PLAYERS<input type=\"text\" name=\"players\">\n"; echo "SET<input type=\"text\" name=\"set\">\n"; echo "<input type=\"hidden\" name=\"schoolid\" value=\"$schoolid\">\n"; echo "<input type=\"hidden\" name=\"content\" value=\"adddouble\">\n"; echo "<br><input type=\"submit\" value=\"Submit\">\n"; echo "</form>\n"; ?> adddouble.inc.php <?php $schoolid =$_POST['schoolid']; $name =$_POST['name']; $players =$_POST['players']; $set =$_POST['set']; $con = mysql_connect("localhost", "xxx", "xxxx") or die('Could not connect to server'); mysql_select_db("bluegray", $con) or die('Could not connect to database'); $query= "INSERT INTO doubles (schoolid, name, players, set)"." VALUES ($schoolid, '$name', '$players', '$set')"; $result = mysql_query($query); if ($result) echo "<h2> SCORES POSTED </h2>\n"; else echo"There was a problemo"; echo "<a href=\"index.php?content=showfullscore&id=$schoolid\">Return to School Scores</a>\n"; ?> HELP PLEASE THANKS Link to comment https://forums.phpfreaks.com/topic/79307-please-help-with-php-coding-problem/ Share on other sites More sharing options...
jcd Posted November 28, 2007 Share Posted November 28, 2007 -mistake- Link to comment https://forums.phpfreaks.com/topic/79307-please-help-with-php-coding-problem/#findComment-401432 Share on other sites More sharing options...
srhino Posted November 28, 2007 Author Share Posted November 28, 2007 - Link to comment https://forums.phpfreaks.com/topic/79307-please-help-with-php-coding-problem/#findComment-401433 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.