I would like to give my users the ability to add content to my site. the amount of stats that they want on our baseball site is too much for me to keep up with, hence wanting to give controll of the content to them.
I have setup a database and one test table. I am able to add data and to display it. i am havin some trouble with extra data being entered when i do not want it. i have an admin area where ive setup two links to the two areas i have tables to input data to. when i click on the links, not the submit buttons on the forms, it enters null data into the DB. im not sure why it is doing this.
here is the code im using:
This adds a player to the hall of fame page. the other bit of code adds a GM to th hall of fame. Once i get this working correctly i will use this to have users add stats and edit errors as well.
-Dave
I have setup a database and one test table. I am able to add data and to display it. i am havin some trouble with extra data being entered when i do not want it. i have an admin area where ive setup two links to the two areas i have tables to input data to. when i click on the links, not the submit buttons on the forms, it enters null data into the DB. im not sure why it is doing this.
here is the code im using:
Code:
<?php
$username="user";
$password="pass";
$database="db";
$Name=$_POST['Name'];
$URL=$_POST['URL'];
$Team=$_POST['Team'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO hof_player VALUES ('','$Name','$URL','$Team')";
mysql_query($query);
mysql_close();
?>
<h3>Add HOF Player to Database</h3>
<form action="<?php echo $PHP_SELF ?>" method="post">
Player Name: <input type="text" name="Name"><br>
Player Page: <input type="text" name="URL"><br>
Inducted Team:
<SELECT name="Team">
<option SELECTED>Choose a Team</option>
<OPTION value="ana">Anaheim</option>
<OPTION value="ari">Arizona</option>
<OPTION value="atl">Atlanta</option>
<OPTION value="bal">Baltimore</option>
<OPTION value="bos">Boston</option>
<OPTION value="chn">Chicago N</option>
<OPTION value="chw">Chicago A</option>
<OPTION value="cinn">Cinncinati</option>
<OPTION value="clev">Cleveland</option>
<OPTION value="col">Colorado</option>
<OPTION value="det">Detroit</option>
<OPTION value="fla">Florida</option>
<OPTION value="hou">Houtson</option>
<OPTION value="kc">Kansas City</option>
<OPTION value="la">Los Angeles</option>
<OPTION value="mil">Milwaukee</option>
<OPTION value="min">Minnisota</option>
<OPTION value="mon">Montreal</option>
<OPTION value="nym">New York N</option>
<OPTION value="nyy">New York A</option>
<OPTION value="oak">Oakland</option>
<OPTION value="phi">Philiadelphia</option>
<OPTION value="pit">Pittsburgh</option>
<OPTION value="sd">San Diego</option>
<OPTION value="sf">San Francisco</option>
<OPTION value="sea">Seattle</option>
<OPTION value="stl">St. Louis</option>
<OPTION value="tb">Tampa Bay</option>
<OPTION value="tex">Texas</option>
<OPTION value="tor">Toronto</option>
<OPTION value="was">Washington</option>
</SELECT>
<br/>
<input type="Submit" Value="Enter Player">
</form>
This adds a player to the hall of fame page. the other bit of code adds a GM to th hall of fame. Once i get this working correctly i will use this to have users add stats and edit errors as well.
-Dave