Problem with database (XAMPP)

Page 1 of 1

1 Replies - 568 Views - Last Post: 06 June 2012 - 10:02 AM Rate Topic: -----

#1 demoloution  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-November 10

Problem with database (XAMPP)

Posted 06 June 2012 - 09:46 AM

Hello all,

i wasnt sure where to post this question, because i have problem with either my database or my php file.
So i have a main.html file and i want through the POST command to allow users to enter book elements like title, isbn, theme etc.
To do this, like i read on tutorials, you need to have a .php file with some commands in it that will allow to send the data inserted by the user to your mysql base (localhost).

I passed through blank pages and browser showing me all my script until i got to this error:

Notice: Undefined index: BOOK_CODE in C:\xampp\htdocs\xalkidi\insertBOOK.php on line 11

Notice: Undefined index: BOOK_ISBN in C:\xampp\htdocs\xalkidi\insertBOOK.php on line 12

Notice: Undefined index: BOOK_TITLE in C:\xampp\htdocs\xalkidi\insertBOOK.php on line 13

Notice: Undefined index: MAIN_THEME in C:\xampp\htdocs\xalkidi\insertBOOK.php on line 14

Notice: Undefined index: PUBLISHER_NAME in C:\xampp\htdocs\xalkidi\insertBOOK.php on line 15

Notice: Undefined index: YEAR_OF_ACQUISITION in C:\xampp\htdocs\xalkidi\insertBOOK.php on line 16

Notice: Undefined index: BOOK_SUMMARY in C:\xampp\htdocs\xalkidi\insertBOOK.php on line 17


my main.html and insertBOOK.php codes are the following :

<html>

<head>
<title> E-Library </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Imagetoolbar" content="no">
<style type="text/css">
html {height:100%;}
body {height:100%; margin:0; padding:0;}
#bg {position:fixed; top:0; left:0; width:100%; height:100%;}
#content {position:relative; z-index:1;}
h1 {font-size: 32pt; color: red}
a {font-size: 24pt; color: blue}
h2 {font-size: 18pt; color: red}
form {font-size: 18pt; color: red}
</style>
</head>

<body>
<div id="bg"><img src="mystery.jpg" width="100%" height="100%" alt=""></div>
<div id="content"> 
<h1 align = center><p>E-Library<p></h1>
<h2><p>Welcome to E-Library, the best place to search&share your favorite books!!!</p></h2>
<a href = "http://en.wikipedia.org/wiki/Digital_library" target = "new"><p> LEARN MORE </p></a>
<a href = "insertBOOK.php" target = "new"><p> test </p></a>
<form name="inputBOOK" action="insertBOOK.php" method="post"><p>
BOOK_CODE: <input type="text" name="BOOK_CODE" />
BOOK_ISBN: <input type="text" name="BOOK_ISBN" />
BOOK_TITLE: <input type="text" name="BOOK_TITLE" />
MAIN_THEME: <input type="text" name="MAIN_THEME" />
PUBLISHER_NAME: <input type="text" name="PUBLISHER_NAME" />
YEAR_OF_ACQUISITION: <input type="text" name="YEAR_OF_ACQUISITION" />
BOOK_SUMMARY: <input type="text" name="BOOK_SUMMARY" />
<input type="submit" value="OK" />
</form></p>
</div> 
</body>

</html>




<?php
$con = mysql_connect("localhost","admin","");

if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("e-library");

$BOOK_CODE = $_POST["BOOK_CODE"];
$BOOK_ISBN =$_POST["BOOK_ISBN"];
$BOOK_TITLE = $_POST["BOOK_TITLE"];
$MAIN_THEME = $_POST["MAIN_THEME"];
$PUBLISHER_NAME = $_POST["PUBLISHER_NAME"];
$YEAR_OF_ACQUISITION = $_POST["YEAR_OF_ACQUISITION"];
$BOOK_SUMMARY = $_POST["BOOK_SUMMARY"];


echo $BOOK_CODE ;
echo $BOOK_ISBN ;
echo $BOOK_TITLE ;
echo $PUBLISHER_NAME ;
echo $MAIN_THEME ;
echo $YEAR_OF_ACQUISITION ;
echo $BOOK_SUMMARY ;


mysql_query("INSERT INTO BOOK (BOOK_CODE, BOOK_ISBN, BOOK_TITLE, MAIN_THEME, PUBLISHER_NAME, YEAR_OF_ACQUISITION, BOOK_SUMMARY)
VALUES ('$BOOK_CODE', '$BOOK_ISBN', '$BOOK_TITLE', '$MAIN_THEME', '$PUBLISHER_NAME, '$YEAR_OF_ACQUISITION', '$BOOK_SUMMARY')");

// some code



mysql_close($con);
?>




I am new to this so any help would be appreciated :)
Thank you

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with database (XAMPP)

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9073
  • View blog
  • Posts: 34,115
  • Joined: 12-June 08

Re: Problem with database (XAMPP)

Posted 06 June 2012 - 10:02 AM

Let's not create duplicate topics.. thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1