close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MySqli Login stay on same page

Thread began 8/29/2019 8:37 am by Adam | Last modified 9/12/2019 10:06 am by Ray Borduin | 1238 views | 13 replies |

Adam

MySqli Login stays on same page

I just set up a page to use as a login, but when I attempt to login, it just stays on the same page and tacks on:

/?username=admin&password=admin&LOGIN=LOGIN

to the end of the url. It never redirects to the success page. The same thing happens when it fails.

I just have a simple form (see below)...and then using the webassist server behavior Login User.

If i change the method to post, it just goes to the failed page no matter what username and password i put in the fields.

Any thoughts?

<form action="" method="get" name="user">    
<div>
<input id="username" name="username" type="text" placeholder="Username...">
</div>
<div>
<input id="password" name="pwd" type="password" placeholder="Password...">
</div>
<div>
<input name="LOGIN" type="submit" value="LOGIN">
</div>
</form>



This is what was automatically added to the page.

<?php require_once('../Connections/Claudia.php'); ?>
<?php require_once('../webassist/mysqli/authentication.php'); ?>
<?php
$Authenticate = new WA_MySQLi_Auth($Claudia);
$Authenticate->Action = "authenticate";
$Authenticate->Trigger = ($_SERVER["REQUEST_METHOD"] === "POST");
$Authenticate->Name = "user";
$Authenticate->Table = "users";
$Authenticate->addFilter("username", "=", "s", "".((isset($_GET["username"]))?$_GET["username"]:"") ."");
$Authenticate->addFilter("password", "=", "s", "".((isset($_GET["pwd"]))?$_GET["pwd"]:"") ."");
$Authenticate->RememberMe = (true);
$Authenticate->SaveLogin = (true);
$Authenticate->AutoReturn = false;
$SuccessRedirect = "home.php";
$FailedRedirect = "fail.php";
if (function_exists("rel2abs")) $SuccessRedirect = $SuccessRedirect?rel2abs($SuccessRedirect,dirname(__FILE__)):"";
if (function_exists("rel2abs")) $FailedRedirect = $FailedRedirect?rel2abs($FailedRedirect,dirname(__FILE__)):"";
$Authenticate->SuccessRedirect = $SuccessRedirect;
$Authenticate->FailRedirect = $FailedRedirect;
$Authenticate->execute();
?>
Sign in to reply to this post

Ray BorduinWebAssist

You are using the trigger "any form post", but you have a form method "get" instead of "post".

I'd fix this by updating your <form> to use post method. Then find and replace any reference to $_GET and change it to $_POST

Sign in to reply to this post
Did this help? Tips are appreciated...

Adam

thank you! i guess i tried those things all separately...but never all at once. Thanks again for your help.

Sign in to reply to this post

Adam

I'm trying the Log In User again on another page...and the form just seems to refresh and never redirects to the index.php page. Any thoughts?



<?php require_once('../Connections/Micro2.php'); ?>
<?php require_once('../webassist/mysqli/authentication.php'); ?>
<?php
$Authenticate = new WA_MySQLi_Auth($Micro2);
$Authenticate->Action = "authenticate";
$Authenticate->Trigger = ($_SERVER["REQUEST_METHOD"] === "POST");
$Authenticate->Name = "user";
$Authenticate->Table = "teachers";
$Authenticate->addFilter("username", "=", "s", "".((isset($_POST["username"]))?$_POST["username"]:"") ."");
$Authenticate->addFilter("password", "=", "s", "".((isset($_POST["password"]))?$_POST["password"]:"") ."");
$Authenticate->storeResult("team", "team");
$Authenticate->storeResult("username", "user");
$Authenticate->RememberMe = (true);
$Authenticate->SaveLogin = (true);
$Authenticate->AutoReturn = false;
$SuccessRedirect = "index.php";
$FailedRedirect = "";
if (function_exists("rel2abs")) $SuccessRedirect = $SuccessRedirect?rel2abs($SuccessRedirect,dirname(__FILE__)):"";
if (function_exists("rel2abs")) $FailedRedirect = $FailedRedirect?rel2abs($FailedRedirect,dirname(__FILE__)):"";
$Authenticate->SuccessRedirect = $SuccessRedirect;
$Authenticate->FailRedirect = $FailedRedirect;
$Authenticate->execute();
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login</title>
<link href="micro.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Fredericka+the+Great|Homenaje&display=swap" rel="stylesheet">
</head>

<body>
<div id="main" align="center">

<div class="header"> LOGIN </div>

<div>
<form action="" method="post">
<div ><label for="username">Username:</label> <input name="username" type="text" id="username"><br></div>
<div ><label for="password">Password:</label> <input name="password" type="password" id="password"><br></div>
<input name="submit" class="submit" type="submit" value="Submit" />
</form>
</div>
<div>

</body>
</html>

Sign in to reply to this post

Ray BorduinWebAssist

Maybe a blank line of code or space in the code? If you attached the page I might be able to spot it.

Sign in to reply to this post
Did this help? Tips are appreciated...

Adam

That was the entire page that is pasted under my question. I attached it as well to this reply.

Attached Files
login.php
Sign in to reply to this post

Ray BorduinWebAssist

That looks ok. Maybe something in your Micro2.php connection file? Usually a redirect not working is because of extra code, errors, or line breaks that appear above the redirect. If I had a URL to redirect and FTP access then I could debug it further for you and try to find the source of the problem.

Sign in to reply to this post
Did this help? Tips are appreciated...

Adam

okay.
it would need to redirect to index.php..and login in private message.
not sure if i did it right, so let me know if it doesn't work.

Sign in to reply to this post

Ray BorduinWebAssist

what is the website url?

Sign in to reply to this post
Did this help? Tips are appreciated...

Adam

micro2.adamhaynes.com

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...