Jump to content

Buttons Not Displaying On 1 IF Statement


Coders2018

Recommended Posts

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.

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.

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.