<?php
// open the connection
$conn = mysql_connect("localhost", "root", "");
// pick the database to use
mysql_select_db("dcdatabase",$conn);
if ($_POST[salewant] == "select") {
print "You didn't specify whether your ticket(s) were for sale or wanted.";
print "<br>";
print "Please use the back button on your browser and try again.";
} elseif ($_POST[event] == NULL) {
print "You didn't specify an event!";
print "<br>";
print "Please use the back button on your browser and try again.";
} elseif ($_POST[venue] == NULL) {
print "You didn't specify a gig venue!";
print "<br>";
print "Please use the back button on your browser and try again.";
} elseif ($_POST[location] == NULL) {
print "You didn't specify a location!";
print "<br>";
print "Please use the back button on your browser and try again.";
} elseif ($_POST[date] == NULL) {
print "You didn't enter any date(s) for the event!";
print "<br>";
print "If you are not sure of the date(s) of the event please go back and enter 'not sure'";
print "<br>";
print "If you want to buy gig ticket(s) and you don't care about the gig date(s), please go back and enter 'any'";
print "<br>";
print "<br>";
print "Use the back button on your browser to go back to your submission form.";
} elseif ($_POST[quant] == NULL) {
print "Could not enter your details. You did not specify how many tickets you wanted to buy or sell!";
print "<br>";
print "Please use the back button on your browser and try again.";
} elseif ($_POST[price] == NULL) {
print "There was no price!";
} elseif ($POST[email] == NULL and $POST[telnum] == NULL) {
print "You need to specify an email address or a telephone number!";
}else {
// create the SQL statement
$sql = "INSERT INTO testtickets values ('', '$POST[salewant]','$POST[event]','$POST[venue]','$POST[location]','$POST[date]','$POST[quant]','$POST[price]','$POST[email]','$_POST[telnum]')";
// execute the SQL statement
if (mysql_query($sql, $conn)) {
echo "<p align='center'>";
echo "<font color='#000000'><b>Thank you! Your details have been added.</b></font>";
} else {
echo "<p align='center'>";
echo "<font color='#990000'><b>Unable to update database. Contact info@topgig.com if you are in need of any assistance.</b><br> (<i>please ignore the above message if it appeared after a recent page refresh!)";
}
}
//DISPLAYING THE DATABASE
print "<br>";
print "<br>";
// open the connection
$conn = mysql_connect ("localhost", "root", "");
// pick the database to use
mysql_select_db ("dcdatabase",$conn);
// create the sql command
$sql = "Select * from testtickets order by event asc";
// execute the sql command
$result = mysql_query($sql, $conn) or die (mysql_error());
echo "<table style='border: 2px; border-style: solid; border-color: #000000; background-color: #FFFFFF; padding: 1px; spacing: 1px; font-family: verdana; font-size: 12px' width='100%' cellpadding='0' cellspacing='0' align='center'>";
echo "<tr>";
echo "<th style='border: 1px; border-style: solid; border-color: #000000; background-color: #009999; padding: 0px; font-family: arial; font-size: 12px' height='13'><font color='#FFFFFF'>For Sale or Wanted</th>";
echo "<th style='border: 1px; border-style: solid; border-color: #000000; background-color: #009999; padding: 0px; font-family: arial; font-size: 12px' height='13'><font color='#FFFFFF'>Event</th>";
echo "<th style='border: 1px; border-style: solid; border-color: #000000; background-color: #009999; padding: 0px; font-family: arial; font-size: 12px' height='13'><font color='#FFFFFF'>Venue</th>";
echo "<th style='border: 1px; border-style: solid; border-color: #000000; background-color: #009999; padding: 0px; font-family: arial; font-size: 12px' height='13'><font color='#FFFFFF'>Location</th>";
echo "<th style='border: 1px; border-style: solid; border-color: #000000; background-color: #009999; padding: 0px; font-family: arial; font-size: 12px' height='13'><font color='#FFFFFF'>Date(s)</th>";
echo "<th style='border: 1px; border-style: solid; border-color: #000000; background-color: #009999; padding: 0px; font-family: arial; font-size: 12px' height='13'><font color='#FFFFFF'>No' of Tickets available or wanted</th>";
echo "<th style='border: 1px; border-style: solid; border-color: #000000; background-color: #009999; padding: 0px; font-family: arial; font-size: 12px' height='13'><font color='#FFFFFF'>Asking Price (per ticket)</th>";
echo "<th style='border: 1px; border-style: solid; border-color: #000000; background-color: #009999; padding: 0px; font-family: arial; font-size: 12px' height='13'><font color='#FFFFFF'>Email Address</th>";
echo "<th style='border: 1px; border-style: solid; border-color: #000000; background-color: #009999; padding: 0px; font-family: arial; font-size: 12px' height='13'><font color='#FFFFFF'>Telephone Number</th></font>";
echo "</tr>";
// go through each row and display data
while ($shit = mysql_fetch_array($result)) {
// give a name to the fields
$id =$shit['id'];
$saleorwanted = $shit['saleorwanted'];
$event = $shit['event'];
$venue = $shit ['venue'];
$location = $shit ['location'];
$date =$shit['date'];
$numticks =$shit['numticks'];
$price =$shit['price'];
$email =$shit['email'];
$telnum =$shit['telnum'];
//print the results on screen
echo "<tr align=center>";
echo "<td style='border: 1px; border-style: solid; border-color: #000000; background-color: #FFFFFF; padding: 0px; font-family: arial; font-size: 12px' height='30' width='6%'>" .$saleorwanted. "</td>";
echo "<td style='border: 1px; border-style: solid; border-color: #000000; background-color: #FFFFFF; padding: 0px; font-family: arial; font-size: 12px' height='30' width='16%'>" .$event. "</td>";
echo "<td style='border: 1px; border-style: solid; border-color: #000000; background-color: #FFFFFF; padding: 0px; font-family: arial; font-size: 12px' height='30' width='11%'>" .$venue. "</td>";
echo "<td style='border: 1px; border-style: solid; border-color: #000000; background-color: #FFFFFF; padding: 0px; font-family: arial; font-size: 12px' height='30' width='10%'>" .$location. "</td>";
echo "<td style='border: 1px; border-style: solid; border-color: #000000; background-color: #FFFFFF; padding: 0px; font-family: arial; font-size: 12px' height='30' width='7%'>" .$date. "</td>";
echo "<td style='border: 1px; border-style: solid; border-color: #000000; background-color: #FFFFFF; padding: 0px; font-family: arial; font-size: 12px' height='30' width='7%'>" .$numticks. "</td>";
echo "<td style='border: 1px; border-style: solid; border-color: #000000; background-color: #FFFFFF; padding: 0px; font-family: arial; font-size: 12px' height='30' width='7%'>" .$price. "</td>";
echo "<td style='border: 1px; border-style: solid; border-color: #000000; background-color: #FFFFFF; padding: 0px; font-family: arial; font-size: 12px' height='30' width='21%'>" .$email. "</td>";
echo "<td style='border: 1px; border-style: solid; border-color: #000000; background-color: #FFFFFF; padding: 0px; font-family: arial; font-size: 12px' height='30' width='14%'>" .$telnum. "</td>";
echo "</tr>";
}
echo "</table>";
?>