Jump to content

PHP is skipping code


awaise17

Recommended Posts

i am creating a login form in which the login credentials will be sent from index.php file to login.php and after validating that the user does not have sent empty fields, he will be directed to my index.php file.

Here is my code

 

<?php
$email = $_POST['email'];
$pass = $_POST['pass'];

if($email=='' || $pass=='')
{
    header("Location: index.php?view=err");
    
    }
else
{
    $data = "Email = $email | Password = $pass".PHP_EOL;

    //open the file and choose the mode
    $fh = fopen("users.txt", "a");


    //writing to the file
    fwrite($fh, $data); //close the file fclose($fh);
    header("Location: index.php") ;
//   echo"code is working fine";

    
    }
?>

 

The upper half of the code is working fine. It is redirecting the user if he leaves some fields empty but it is not working for the else condition.
It saves the data to users.txt file but it does not redirect the user to index.php
Then i just used echo statement but it is also not working...so php is skipping the code under fwrite...

Edited by awaise17
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.