Here is the code for my first page
<html>
<body>
<?php
$conn = mysql_connect("localhost", "root", "")
or die ("Could not connect to server");
$db = mysql_select_db ("customer", $conn)
or die ("Couldnt select database");
$query = "SELECT * FROM `fixtures` WHERE `fixtureID` BETWEEN 1 AND 10";
$result = mysql_query ($query)
or die ("Query failed: ".mysql_error());
?>
<form name="fixturesEnglish" action="betplacedSpain.php" method="POST">
<table border = "0">
<tr>
<td><b>Home</b></td>
<td><b>Draw</b></td>
<td><b>Away</b></td>
</tr>
</table>
<table>
<?
while ($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>",$row['fixtureID'],
"<input type='radio' name='fixture' value=",$row['team1'],
">",$row['team1'],
"</td><td><input type='radio' name='fixture' value='draw'>", "Draw",
"</td><td><input type='radio' name='fixture' value=",$row['team2'],
">",$row['team2'];
echo "</td></tr>";
}
mysql_close($conn);
session_register();
$_SESSION['fixtureID'] = $fixtureID;
?>
</table>
<input type ="submit" name = "bet" value = "Bet"/>
<INPUT type="button" value="Place Bet!" onClick="window.open('http://localhost/phpcode/betplacedSpain.php','mywindow','width=400,height=400')"/>
</form>
</body>
</html>
This is the code for the page that shows the data
<?php
session_start(username);
$_SESSION['username'];
?>
<html>
<head>
<script type="text/javascript" language ="Javascript">
function Validate()
{
var problem = 'No';
if (document.bet.userName.value =="")
{
alert("Please Login to place a bet.");
document.bet.userName.focus();
problem = 'Yes';
}
if (document.bet.amount.value =="")
{
alert("You forgot the amount to Wager!");
document.bet.amount.focus();
problem = 'Yes';
}
if (problem == 'No')
{
return true;
}else
{
return false;
}
}
</script>
<title>Bet Slip</title>
<link rel=stylesheet href="Stylesheet.css" type="text/css">
</head>
<body>
<img src = "images/betLogo.gif"/>
<p/>
<?php
$fixture=$_POST['fixture'];
$fixtureID=$_GET['fixtureID'];
$userName=$_POST['username'];
$team1=$_POST['team1'];
$team2=$_POST['team2'];
session_start();
$_SESSION['fixture'] = $fixture;
$userName=$_SESSION['username'];
$_SESSION['team1'] = $team1;
$_SESSION['team2'] = $team2;
//database connection
$conn = mysql_connect("localhost", "root", "") or die('could not connect to mysql' .mysql_error());
mysql_select_db('customer', $conn) or die('could not connect to DB' .mysql_error());
//this needs to be modified to take the value in the username session
$query = "SELECT * FROM customerdetails WHERE userName like '$userName' ";
//show user details on my account
$result = mysql_query ($query)
or die ("Query failed: ".mysql_error());
while ($row = mysql_fetch_array($result))
{
$row['amount'];
$amount1 = $row['amount'];
}
echo "<form name = 'bet' action='confirmBet.php' method='post' onsubmit='return Validate()'>";
echo "Bet Choice : '<tt>$fixture</tt>'<p/>";
echo "Time :";
echo date("H:i:<p/>");
echo "User Name:<input type='text' readonly = 'readonly' size ='5' name='userName' value = '";
echo $_SESSION['username']; echo "'><p/>";
echo "Balance:" ; echo $amount1; echo "<p>";
echo "Amount: €<input type='text'size ='5' name='amount'><p/> ";
echo "<input type='submit' value='Place Bet'> ";
echo "</form>";
print_r($_SESSION);
session_write_close();
?>
</body>
</html>