Hi
I have a very basic question. Is it possible to change the text of a page after submitting a form on another page?
A particular example is given as under:
I have a login link on 'index.php' page, and when it is clicked, a new (_blank) page 'login.php' opens. This page contain a form having username and password. When a user submit the form, another page authenticate the user.
If the user is a valid user, then I need to display "Welcome username" on 'index.php' page, dynamically.
I added the code below. What I need to add to accomplish this?
index.php
<?php
if ($_COOKIE['cookieName']) { echo '<li>Welcome '. $_COOKIE['cookieName']; echo'|'; echo '<a href="logout.php" target="_blank">Logout</a> </li>'; }
else {echo' <li><a href="login.php" target="_blank" class="login">Login</a> | <a href="user_add.php" target="_blank" class="login">Register</a></li> '; }
?>
login.php
<form action="checklogin.php" method="post" name="form" id="form">
<input type="text" name="username" value = '' />
<input type="password" name="password" value = '' />
<input name="submit" type="submit" value="Log me in." class="button"/>
checklogin.php
$sql="SELECT * FROM users WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table rows
$count=mysql_num_rows($result);
if($count==1){
$cookie_name ="$cookiename";
$cookie_expire ="300";
setcookie($cookie_name,$cookie_value,time() + (300),"/", $cookie_domain);
header("location:$successfulLogin_url");
//I need some code here that somehow change the text in the index.php file dynamically
}
else{
header("location:$failedLogin_url");
}
Thanks in advance