Coders2018 Posted July 9, 2010 Share Posted July 9, 2010 Hello, I'm having problems getting two buttons to display at the side of an IF statement once it executes true. All the other IF statements in my code are displaying and working with the buttons at the side. This one is doing my head in and I can't find what the problem is. This is the IF statement that when it executes true it doesn't display the two buttons it's supposed to like all the others do. if($home_team == $away_team) { echo "Your not allowed to enter the same team."; exit; } Any help as always is appreciated. Quote Link to comment Share on other sites More sharing options...
joel24 Posted July 10, 2010 Share Posted July 10, 2010 where's the HTML for the two buttons being echoed? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 10, 2010 Share Posted July 10, 2010 If what you have there evaluates as true, it simply echos "You're not allowed to enter the same team". Quote Link to comment Share on other sites More sharing options...
Coders2018 Posted July 10, 2010 Author Share Posted July 10, 2010 The HTML I've got in my add_fixtures.php is outside my the PHP code and looks like this: The full script looks like this: <html> <head><title>Adding Fixtures</title></head> <body style="background-color:grey; font-family:arial; color:white;"> <center> <table> <tr><td> <form action="add_fixtures.htm" method="post"> <?php require_once("database_connect.php"); $home_team = $_POST['Home_Team_Fixture']; $away_team = $_POST['Away_Team_Fixture']; $fixture = $home_team." v ".$away_team; [b] if($home_team == $away_team) { echo "Your not allowed to enter the same team."; exit; } [/b] $check_query = "SELECT * FROM Fixtures WHERE Fixture ='$fixture'"; $checking = mysql_query($check_query); $check = mysql_fetch_array($checking); if($check) { echo "This Fixture is Already In Place"; } else { $query = mysql_query("INSERT INTO Fixtures (Fixture) VALUES ('$fixture')"); if($query) { echo "You've successfully added the $fixture fixture into the league"; } } ?> <input type="submit" name="Add_Another_Fixture" value="Add Another Fixture"> </form> </td> <td> <form action="view_fixtures.php" method="post"> <input type="submit" name="View_Fixtures" value="View Fixtures"> </form> </td> </tr> </table> </center> </body> </html> Please note that this script works fine and all the other if and else statements have buttons placed at the side of them apart from the bold if statement. I want the part highlighted in bold to have the 2 buttons at the side of the echoed out text like all of the others do. Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted July 10, 2010 Share Posted July 10, 2010 if you want the html in the bottom of the page to load you cannot exit the php script that stops the page from loading. Simple solution delete exit; and if you didn't want the rest of the script to load also then use }else{ non loading script } <html> <head><title>Adding Fixtures</title></head> <body style="background-color:grey; font-family:arial; color:white;"> <center> <table> <tr><td> <form action="add_fixtures.htm" method="post"> <?php require_once("database_connect.php"); $home_team = $_POST['Home_Team_Fixture']; $away_team = $_POST['Away_Team_Fixture']; $fixture = $home_team." v ".$away_team; if($home_team == $away_team) { echo "Your not allowed to enter the same team."; }else{ $check_query = "SELECT * FROM Fixtures WHERE Fixture ='$fixture'"; $checking = mysql_query($check_query); $check = mysql_fetch_array($checking); if($check) { echo "This Fixture is Already In Place"; } else { $query = mysql_query("INSERT INTO Fixtures (Fixture) VALUES ('$fixture')"); if($query) { echo "You've successfully added the $fixture fixture into the league"; } } } ?> <input type="submit" name="Add_Another_Fixture" value="Add Another Fixture"> </form> </td> <td> <form action="view_fixtures.php" method="post"> <input type="submit" name="View_Fixtures" value="View Fixtures"> </form> </td> </tr> </table> </center> </body> </html> Quote Link to comment Share on other sites More sharing options...
Coders2018 Posted July 10, 2010 Author Share Posted July 10, 2010 Thanks for that my script now works perfectly exactly as I wanted too. I've been struggling for the last day with that and I always had some feeling it was stopping the script but wasn't 100% sure. Thanks for all the help given Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.