Jump to content

Please help with php coding problem


srhino

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.