Hi Guys i am having a very peculiar problem i have written a small code so that it is possible to sign up to the website i am creating with a few restrictions to each field however from what i see the code seems ok but each time i try to use the php code with html code the browser is always printing part of the code like this:

"11){ echo 'Username needs at least 6 and maximum 11 characters'; } else if (strpos($Username, '@') != 0) { echo ' Username cant be your email'; } ?>"

        <?php

            $Username = 'aasd';

                if (strlen($Username) < 6 || strlen($Username) > 11){ 
                 echo 'Username needs at least 6 and maximum 11 characters';
         }
         else if (strpos($Username, '@') != 0) {      
               echo ' Username cant be your email';
         } 

            ?>

From what i can see the code is correct but i can't seem to find the reason as to why this is happening am i missing something in the PHP code? do i have some condition or operator that is not set in the right way?

Thank you first hand to all those who reply

It's working fine here. I can however reproduce that exact print by renaming the php file to html. PHP code can't be inserted into an html file, you'll have to make it a php file instead (in other words, rename it so the file ends on .php).

Keep in mind that php files need to be run on a server. An easily configurable one like XAMPP for instance.

If you want to develop without worries, I always recommend Cloud9 IDE. It's all in the cloud and very easy to use. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.