I need a help about redirection. I have a form that is written in HTML simple form. It is getting username and password and posting them to another php file. This PHP file is checking user and password if it is false; I want to redirect to back form file in order to get username and pasword again. But before redirection to form page, I want to show the user there is error and redirectin message. Maybe, we can show this message in form page, maybe before redirection. How can we handle this ? COuld you please help me for this?
FORM FILE:
<html>
<body>
<form action="cvphost.php" method="post">
Username: <input type="text" name="username"><br>
Password: <input type="text" name="password"><br>
<input type="submit">
</form>
</body>
</html>
PHP FILE:
<pre>
<?php
#GETTING EXISTING HOST FILE OF ANSIBLE
$host_file=file('/etc/ansible/hosts');
#GETTING VALUE OF USERNAME,PASS LINE OF HOSTFILE
$ansibleusername=$host_file[7];
$ansiblepassword=$host_file[8];
#PARSING USERNAME AND PASS LINE OF THAT HOST FILE
$list1=split('=',$ansibleusername);
$list2=split('=',$ansiblepassword);
#UPDATING USERNAME AND PASS FROM FORM
$list1[1]=$_POST["username"];
$list2[1]=$_POST["password"];
#JOINING WITH NEW VALUE AND INSERTING HOST-FILE LINES
$array1=array($list1[0],$list1[1]);
$array2=array($list2[0],$list2[1]);
$newansibleusername=join("=",$array1);
$newansiblepassword=join("=",$array2);
$host_file[7]=$newansibleusername."\n";
$host_file[8]=$newansiblepassword."\n";
#PUSHING NEW FILE TO ANSIBLE HOST FILE
$updated_host_file=file_put_contents('/etc/ansible/hosts',$host_file, LOCK_EX);
#usleep(1000);
#chdir('/etc/ansible/');
#$pwd=shell_exec('pwd');
#$task=shell_exec('ansible-playbook user-login-playbook.yml');
#echo $task;
#echo $pwd;
$log_file=file('/etc/ansible/log/user-login-playbook-log.txt');
***#THIS PART IS REDIRECTION PART OF MY CODE. ABOVE IS CORRECT, I WANT FIX BELOW PART***
if ($log_file[0]=="YOU CAN MANAGE CVP NOW")
{ print_r ($log_file[0]);}
else
{ print_r ($log_file[1])."\n";
print "<pre>";
print_r('REDIRECTING TO LOGIN PAGE!...');
}**