garrensilverwing
New Member
- Messages
- 148
- Reaction score
- 0
- Points
- 0
i'm trying to build a database full of information on games that i have on my site the problem i am having is the information is not storing in the database (i get no error messages)... here is my code thanks for the help in advance
for gamesdb.php:
for ../dbgames_connect.php:
Edit:
well i figured it out on my own, thanks for not calling me an idiot anyone i had to change the name of my submit button to submit not Submit1 which wast he default haha
for gamesdb.php:
Code:
<?php
require "../dbgames_connect.php";
if(!$_POST['submit']) {
?>
<html>
<head>
<title>add games to database</title>
</head>
<body>
<div>
<form method="post" action="gamesdb.php">
<input name="wFirst" type="text" tabindex="1" style="height: 22px"> white first name<br>
<input name="wLast" type="text" tabindex="2"> white last name<br>
<input name="wRating" type="text" tabindex="3"> white rating<br>
<input name="bFirst" type="text" tabindex="4"> black first name<br>
<input name="bLast" type="text" tabindex="5"> black last name<br>
<input name="bRating" type="text" tabindex="6"> black rating<br>
<input name="eco" type="text" tabindex="7"> eco<br>
<input name="result" type="text" tabindex="8"> result<br>
<input name="year" type="text" tabindex="9"> year<br>
<input name="link" type="text" tabindex="10"> link<br>
<input name="Submit1" type="submit" value="submit" tabindex="11"></form>
</div>
</body>
</html>
<?php
}
else {
$wFirst=protect($_POST['wFirst']);
$wLast=protect($_POST['wLast']);
$wRating=protect($_POST['wRating']);
$bFirst=protect($_POST['bFirst']);
$bLast=protect($_POST['bLast']);
$bRating=protect($_POST['bRating']);
$eco=protect($_POST['eco']);
$result=protect($_POST['result']);
$year=protect($_POST['year']);
$link=protect($_POST['link']);
$sql = "INSERT into `games`(`wFirst`,`wLast`,`wRating`,`bFirst`,`bLast`,`bRating`,`eco`,`result`,`year`,`link`)
VALUES ('$wFirst','$wLast','$wRating','$bFirst','$bLast','$bRating','$eco','$result','$year','$link');";
mysql_query($sql) or die(mysql_error());
echo "Thank you for submitting the game information.";
}
?>
Code:
<?php
$username = "frostbit_admin";
$password = "***";
$server = "localhost";
$database="frostbit_games";
$mysqlconnection = mysql_connect($server, $username, $password);
if (!$mysqlconnection) {
die('There was a problem connecting to the mysql server. Error returned: '. mysql_error());
}
$databaseconnection = mysql_select_db($database);
if (!$databaseconnection) {
die('There was a problem using that mysql database. Error returned: '. mysql_error());
}
function protect($string)
{
$string = mysql_real_escape_string($string);
return $string;
}
?>
well i figured it out on my own, thanks for not calling me an idiot anyone i had to change the name of my submit button to submit not Submit1 which wast he default haha
Last edited: