hi i'm new to php and i have problem with header i try to redirect to home page but when i use header nothing happend i tried it in anther page and work but i don't know why it don't work here

<?php session_start(); ?>
<?php ob_start();?>

<form action="index.php" method="POST">
         <?php //value='$username ' this funcation will not reset username?>
            <td>username :</td><td><input type="text" name="user_name" value="<?php echo $username ?>" ></td>
            <td>Passwored :</td><td> <input type="password" name="pass"></td>
            <td><input type="submit" value="submit" name="submit"></td>
            <td><a href="register.php">new account</a></td>



        if (isset($_POST['user_name'])&&isset($_POST['pass'])){

            $username =htmlentities($_POST['user_name']);
            $pass =htmlentities($_POST['pass']);

            if ((3>strlen($username))||(strlen($username)>20)){
                echo 'username must be long than 5 and  less than 20 ';

            if (6>$pass||$pass<20){
                echo " passwored must be long than 6 and  less than 20 ";

            $con=mysql_connect('localhost','root','fuckyou1.') || die("can't acsess database");

            $db = mysql_select_db("register");

            $query=mysql_query("select * from login where username='$username' and pass='$pass'");

            while ($result=mysql_fetch_assoc($query)){

                if ($db_username==$username&&$db_pass==$pass){
                    echo $username;
                }else {
                    echo "user not found";

<?php ob_flush();?>

Recommended Answers

All 2 Replies

header doesn't work if you already outputted html (your form), before calling it.

thanks for helping it work now 
Be a part of the DaniWeb community

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