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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.