Hi,
I’m having problems when loading a page, it’s adding blank database to my MySQL table.
What have i done wrong that is causing blank data to be in putted when loading the page?
I have the following;
Index.php
– Shows 2 links, 1 to add, 1 to display
addtour.php
– 4 input boxes and 1 submit button
showtour.php
– Shows the details added from the above page.
[size=12pt]INDEX.PHP[/size]
<html>
<head>
<title>Title</title>
</head>
<body>
<h3>Header</h3>
<a href="addtour.php">Add Show</a> | <a href="showtour.php">Show Dates</a>
</body>
</html>
[size=12pt]ADDTOUR.PHP[/size]
<html>
<head>
<title>Titlen</title>
</head>
<body>
<h3>Header</h3>
<a href="addtour.php">Add Show</a> | <a href="showtour.php">Show Dates</a>
<br>
<form action="addtour.php" method="post">
Location: <input type="text" name="TourLocation"><br>
Date: <input type="text" name="TourDate"><br>
Time: <input type="text" name="TourTime"><br>
Comments: <input type="text" cols="45" name="TourComments"><br>
<input type="Submit">
</form>
<br>
<?php
$dbhost="xxx";
$username="xxx";
$password="xxx";
$database="xxx";
$TourLocation=$_POST['TourLocation'];
$TourDate=$_POST['TourDate'];
$TourTime=$_POST['TourTime'];
$TourComments=$_POST['TourComments'];
mysql_connect($dbhost, $username, $password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO TableName VALUES ('','$TourLocation','$TourDate','$TourTime','$TourComments')";
mysql_query($query);
mysql_close();
?>
</body>
</html>
[size=12pt]SHOWTOUR.PHP[/size]
[code]
TitleShow Details
Add Show | Show Dates
<?php $dbhost="xxx"; $username="xxx"; $password="xxx"; $database="xxx"; mysql_connect($dbhost, $username, $password); @mysql_select_db($database) or die( "Unable to connect to the database"); $query="SELECT * FROM TableName Order By TourID DESC"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?>
Location | Date | Time | Other Information |
---|---|---|---|
<?php echo $f1; ?> | <?php echo $f2; ?> | <?php echo $f3; ?> | <?php echo $f4; ?> |