I was trying to make a popup php form and login popup pages and I fortunately I got some notes and resources from the net on how to design and create what I was up to. The only problem now is that whenever I submit the form or the login popup page, the error messages throw the page back from the popup to original page, which is not what I want. I believe there is a way how to do the validation in the same login/ form page that can take place in the same popup window. any idea how to do that??
Looking forward to hearing from you.
if a code or anything related is required, I would post it here and update the original question.
update#1: here is the code. P.S. this code goes between the body tages
<?php
if ($username && $userid){
echo "You are already logged in as <b>$username</b>. <a href='./member.php'>Click here</a> to go to the member page...or <a href='./logout.php'>Logout</a>";
}
else{
$form = "<form action='./login.php' method='post' id='loginform'>
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='user' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password' /></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='loginbtn' value='Login' /></td>
</tr>
<tr>
<td><a href='./register.php'>Register</a></td>
<td><a href='./forgotpass.php'>Forgot your password?</a></td>
</tr>
</table>
</form>";
if ($_POST['loginbtn']){
$user = $_POST['user'];
$password = $_POST['password'];
if ($user){
if ($password){
require("connect.php");
$password = md5(md5("kj87fiJAR46ufj".$password."Fj754456fj"));
// make sure login info correct
echo"$password";
$query = mysql_query("SELECT * FROM users WHERE username='$user'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$dbid = $row['id'];
$dbuser = $row['username'];
$dbpass = $row['password'];
$dbactive = $row['active'];
if ($password == $dbpass){
if ($dbactive == 1){
// set session info
$_SESSION['id'] = $dbid;
$_SESSION['username'] = $dbuser;
echo "You have been logged in as <b>$dbuser</b>. <a href='./member.php'>Click here</a> to go to the member page.";
}
else
echo "You must activate your account to login. $form";
}
else
echo "You did not enter the correct password. $form";
}
else
echo "The username you entered was not found. $form";
//mysql_close();
}
else
echo "You must enter your password. $form";
}
else
echo "You must enter your username. $form";
}
else
echo $form;
}
?>
and there is a code for the popup.
update#2: If found a similar tut that show how to build a complete login page with popup so I;m going to start from there: enter link description here
Thanks,
Use ajax to do so.
For the login example:
send and ajax request with the credentials
do an action via javascript, depending on the result received by the server. For example, if request result is false show an error, if result is true close the popup and redirect the parent window if needed.
Just an example (neither tested nor working) to guide you do this
1) Include the ajax requests on the js code included in your popup
2) Implement your php file (or preferred server side languaje) to login the user and generate the http response
//your_server_file_that_generates_ajax_response.php