0

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

Edited by reynaud0000: Better organization of the code

3
Contributors
2
Replies
16
Views
2 Years
Discussion Span
Last Post by matrixdevuk
1

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.