== not working

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
vknehra07
New php-forum User
New php-forum User
Posts: 3
Joined: Wed Jul 25, 2018 8:58 am

Wed Jul 25, 2018 9:04 am

Hi,
i am new in php but not in programming
else portion is working perfectly but not if
i am entering the same value which i enter for comparison

please help

thanks

Code: Select all

<body>
    
        <?php
        $name=$_POST['fname'];
        $lname=$_POST['lname'];
        $pass=$_POST['pass'];    
            
            
            
           
        
        if($name == "vivek"){ ?>
            
            <p>Great Job !</p>
            
    <?php } 
        
     else{ ?>
            <p><?php echo $name ; ?> </p>
         <?php } ?>
        
        
        <p><?php echo"$name"; ?></p>
        <p><?php echo"$lname"; ?></p>
        <p><?php echo"$pass"; ?></p>
        
        
    </body>

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 719
Joined: Mon Feb 22, 2016 5:52 pm

Wed Jul 25, 2018 2:38 pm

Do you have error messages on display? if so what errors are you getting, if not - turn them on and see what messages you get.

Are you entering "vivek" in lower case?

Is your form method post?

User avatar
benanamen
New php-forum User
New php-forum User
Posts: 53
Joined: Mon Oct 16, 2017 1:06 pm

Wed Jul 25, 2018 7:04 pm

Jumping in and out of Php seven times for a paragraph of code that only needs to be two lines is very sloppy. Do not create variables for nothing either.

The whole mess can simply be

Code: Select all

<?php
echo $_POST['fname'] == 'vivek' ? '<p>Great Job !</p>' : $_POST['fname']; 
echo "<p>{$_POST['lname']}</p><p>{$_POST['pass']}</p>";

KISS
The XY Problem
The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

vknehra07
New php-forum User
New php-forum User
Posts: 3
Joined: Wed Jul 25, 2018 8:58 am

Thu Jul 26, 2018 2:40 am

hyper wrote:
Wed Jul 25, 2018 2:38 pm
Do you have error messages on display? if so what errors are you getting, if not - turn them on and see what messages you get.

Are you entering "vivek" in lower case?

Is your form method post?

no error message , how to turn on i don't know , yes "vivek" is in lower case also in input , yes it is post method


actually now i solve this with just entering this

Code: Select all


 <?php
        $name=$_POST['fname'];
        $lname=$_POST['lname'];
        $pass=$_POST['pass'];    
            
            ?>
            
           <?php
        
        if($name == 'vivek'){ ?>
            
            <p>Great Job !</p>
            
    <?php } 
        
     else{ ?>
            <p><?php echo $name ; ?> </p>
         <?php } ?>
        
       





another "php code start just before if statement"

vknehra07
New php-forum User
New php-forum User
Posts: 3
Joined: Wed Jul 25, 2018 8:58 am

Thu Jul 26, 2018 2:48 am

benanamen wrote:
Wed Jul 25, 2018 7:04 pm
Jumping in and out of Php seven times for a paragraph of code that only needs to be two lines is very sloppy. Do not create variables for nothing either.

The whole mess can simply be

Code: Select all

<?php
echo $_POST['fname'] == 'vivek' ? '<p>Great Job !</p>' : $_POST['fname']; 
echo "<p>{$_POST['lname']}</p><p>{$_POST['pass']}</p>";

KISS


i solved buddy anyway thanks for help....but it's so confusing also...

Post Reply