Login Form

User 2796854 Photo


Registered User
44 posts

Hi all,

I am trying to create a simple login form using WFB but the form is acting more like a submit form. my final goal is to have users redirected according to their user setup. Bu baby steps - first trying to get a login form to act like a login form.

Here is what I did:

1. Created a new WFB from
2. In sittings I entered the information for my server/database/table
3. Added HTML element and added the code below
4. I exported the project
5. When I try to login using a user that was added to my db/table using my register form; the form submission confirmation page loads.


The code: the following code in my html Element:

<?php

$email = $_POST['email'];
$password2 = $_Post['password2'];
$sql = "SELECT * FROM user_data WHERE email= '$email' AND password2='$password2'";
$result = mysqli_query($conn, $sql);
if (!$row = mysqli_fetch_assoc($result))
{
echo "Your username or password is incorrect!"; }
else { echo "You are logged in!"; }
?>

<form method='POST'>
<label>Email: <input "email" name="email">
<label>Password: <input "password" name="password2">
<button type="submit">Login</button>
</form>

User 187934 Photo


Senior Advisor
18,576 posts
Online Now

The form builder doesn't have the ability to be a login form built in. It does have a password element for creating a user line up form. I use an external php script for my logins and then only use the html generated by the form builder for the form. Try googling php login script and several will come up.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
https://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
https://progrower.coffeecup.com/shop/
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2796854 Photo


Registered User
44 posts

Eric Rohloff wrote:
The form builder doesn't have the ability to be a login form built in. It does have a password element for creating a user line up form. I use an external php script for my logins and then only use the html generated by the form builder for the form. Try googling php login script and several will come up.


Thanks Eric.

I have been working on trying to create a login script outside of WFB and figured once I got that working I'll work to incorporate it with the signup form that I've put together in WFB.

Having difficulty getting the login form to work. If I post the work I have done so far will take a look and let me know where you think the issue is? been googling so much that I think alphabet is going to start charging. LOL.
User 187934 Photo


Senior Advisor
18,576 posts
Online Now

It's really much easier to use a free prebuilt script. A lot of them have features that you will struggle with implementing if you try coding them yourself. It's much easier to replace the the scripts login form with the one made in the form builder.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
https://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
https://progrower.coffeecup.com/shop/
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2736027 Photo


Registered User
58 posts

Tim,

As Eric suggests, first try one of the many 3rd party php log-in scripts available on-line, to see if it gets you what you need.

I've tried http://www.codingcage.com/2015/01/user-registration-and-login-script-using-php-mysql.html. It uses the SESSION variable to see if a user is logged in, or not. Once set, the user can continue further.
User 2796854 Photo


Registered User
44 posts

Thanks Norm and Eric for the direction.

I needed something simpler than the custom scripts I found. But managed to use those asa template with the help of a bunch of youtubing :)

It works!!

<?php

session_start();
include '../dbh.php';

$uid= $_POST['uid'];
$pwd= $_POST['pwd'];


$sql = "SELECT * FROM user WHERE uid='$uid' AND pwd='$pwd'";

$result = mysqli_query($conn, $sql);


if (!$row=mysqli_fetch_assoc($result))
{
//$_SESSION['id'] = $row['id'];
echo "Your username or password is incorrect";
} else {
//echo "You are logged in!!";
$_SESSION['id'] = $row['id'];
}

header("location: ../index.php");

?>
User 516268 Photo


Registered User
57 posts

Where is this php information to be added? I created a form as a login, which I understand needs to be linked to my database and additional code is needed to make it work, but where do I put this additional php code to make it all work?
Woofs & Hoofs Animal Massage - "Helping your pet feel good, naturally!"
www.woofsandhoofs.be
User 187934 Photo


Senior Advisor
18,576 posts
Online Now

Any code you add would depend on how you want users to interact with the site.With the above code it looks as though the user is using the redirect method of the form builder and redirecting to a page with that code on it. The code checks the database for the users info and redirects to the index.php if they are valid. If they aren't valid it gives a error. You could easily send them back to the form to login and show the error.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
https://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
https://progrower.coffeecup.com/shop/
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 516268 Photo


Registered User
57 posts

Thanks Eric. I'll see if I can figure it out.
Woofs & Hoofs Animal Massage - "Helping your pet feel good, naturally!"
www.woofsandhoofs.be

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.