Buy Now
Sign in

How to load data from database and use in custom code?

abhishekpatil , January 07 at 08:23
A
abhishekpatil
Hello,
I am making a form to parse user from my WordPress to Moodle. I want that, the username (PRN No. in my case) and password should save in database on first login(which is working well). After whenever user go to that form, form should load data from database and fill that custom code so user automatically log in. I have placed DB read on load if yes then it should run that script if no, it should render form and all. But the places are vacant which I want to load from database.
A
abhishekpatil
Here is my that custom code,
    <form class="loginform" name="login" method="post" action="http://210.212.172.216/electronics/login/index.php">
<p>

<input type="hidden" name="username" value="{uname}">
</p>
<p>
<input size="20" type="hidden" name="password" type="password" value="{password2}"/>
</p>
<p> You will be redirected soon, if not, click
<input name="Login" id="sub" value="Here" type="submit" />
</p>
</form>
<script type="text/javascript">
setTimeout(function(){ document.getElementById('sub').click(); }, 1000); // 5 seconds
</script>
A
abhishekpatil
@GreyHead, do you have any solution?
GreyHead
Hi abhishekpatil ,

Sorry for the slow reply - I have been ill for the last week and not checking the forum much.

I'm also sorry that I have no idea what you need to do here - that looks like a custom form to be used in a Thank You message in which case your DB Read would need to be in the same action before the Thank You message.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
A
abhishekpatil
I want to parse user to Moodle. Means, user will enter PRN No. and Password, input we have to take using chronoforms, and that fields should save in database. After, that field valu will be assigned to other variables as mentioned in above program and I will run that custom code which will login user in Moodle. The sentence underlined had not any relationship with chronoform, so dont think about it,
Only I want to know that, there is a form, once user will enter value in form, and from next time, value should automatically appear there. So what will be the conditions and all? Am using chronoforms V5.

variables i want to load :

uname
password2
GreyHead
Hi abhishekpatil,

You can save user data to a database table and then re-load that when the user returns - but to do so you have to be able to recognise the user somehow. Either they log in or they provide a unique identifier like a username.

Bob

PS Be very careful saving usernames and passwords of any kind in database tables!! They should at the least be carefully encrypted, and IMHO should only be used for passwords that you have created for them.
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
A
abhishekpatil
As per your suggestions, I kept username same, means username will be passed as current logged in user, but how to encrypt and store password using chronoform?
Is it possible using chronoform?

If yes, then how to load it again by decrypting?
GreyHead
Hi abhishekpatil,

You can use PHP to encrypt/decrypt a string - there are various libraries available.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much