Should the form not show as server connect form under app structure? I am problem-solving a 401 issue.
Your screenshot looks just fine.
401 error means that your user is unathorized.
thanks Teo.
that’s strange as the 401 is from the server action file, and is just a database insert
<?php
require('../../../dmxConnectLib/dmxConnect.php');
$app = new \lib\App();
$app->define(<<<'JSON'
{
"meta": {
"options": {
"linkedFile": "/guest_LogIn.php",
"linkedForm": "form1"
},
"$_POST": [
{
"type": "text",
"fieldName": "name",
"options": {
"rules": {
"core:required": {
"param": ""
}
}
},
"name": "name"
},
{
"type": "text",
"fieldName": "email",
"options": {
"rules": {
"core:email": {
"param": ""
}
}
},
"name": "email"
},
{
"type": "text",
"fieldName": "mobile",
"options": {
"rules": {
"core:required": {
"param": ""
}
}
},
"name": "mobile"
},
{
"type": "text",
"fieldName": "password",
"options": {
"rules": {
"core:required": {
"param": ""
}
}
},
"name": "password"
},
{
"type": "text",
"fieldName": "password2",
"options": {
"rules": {
"core:required": {
"param": ""
},
"core:equalTo": {
"param": "password",
"message": "Your passwords do not match"
}
}
},
"name": "password2"
}
]
},
"exec": {
"steps": {
"name": "insert",
"module": "dbupdater",
"action": "insert",
"options": {
"connection": "connection1",
"sql": {
"type": "insert",
"values": [
{
"table": "customers",
"column": "name",
"type": "text",
"value": "{{$_POST.name}}"
},
{
"table": "customers",
"column": "Password",
"type": "text",
"value": "{{$_POST.password2.sha256('LOHLET8')}}"
},
{
"table": "customers",
"column": "mobile",
"type": "text",
"value": "{{$_POST.mobile}}"
},
{
"table": "customers",
"column": "email",
"type": "text",
"value": "{{$_POST.email}}"
}
],
"table": "customers",
"returning": "idno",
"query": "INSERT INTO customers\n(name, Password, mobile, email) VALUES (:P1 /* {{$_POST.name}} */, :P2 /* {{$_POST.password2.sha256('LOHLET8')}} */, :P3 /* {{$_POST.mobile}} */, :P4 /* {{$_POST.email}} */)",
"params": [
{
"name": ":P1",
"type": "expression",
"value": "{{$_POST.name}}"
},
{
"name": ":P2",
"type": "expression",
"value": "{{$_POST.password2.sha256('LOHLET8')}}"
},
{
"name": ":P3",
"type": "expression",
"value": "{{$_POST.mobile}}"
},
{
"name": ":P4",
"type": "expression",
"value": "{{$_POST.email}}"
}
]
}
},
"meta": [
{
"name": "identity",
"type": "text"
},
{
"name": "affected",
"type": "number"
}
],
"output": true
}
}
}
JSON
);
?>
What’s the exact error message in your server action? Please post a screenshot of the dev tools showing it.
Can you send me a link to your page with the login details so that i can test it?
sure its at https://loveyurt.co.uk/guest_Register.php
Not sure what you have done exactly, but it doesn’t seem you selected a server action to the form:
<form method="post" id="register" is="dmx-api-form">
also it’s set to api-form
while it needs to be to a server connect form.
EDIT:
I now see the correct form options are set.
Just remove what’s added there (using the X), refresh design view/app connect and make the form a server connect form then select the server action again …
Well your guestregister server action returns unauthorzied. Are you sure you don’t have any GLOBAL steps such as Security Restrict added which might be causing this?
I am referring to the global Steps. Click GLOBALS and check if you have anys steps there.
Brilliant troubleshooting thanks Teo
Teo I am still unable to load the user details. I have started again, rebuilt it but the same result. I believe the problem is in the security provider, as the query returns null
{
“query”: {
“options”: {
“connection”: “connection1”,
“sql”: {
“type”: “select”,
“columns”: [
{
“table”: “customers”,
“column”: “name”
}
],
“table”: {
“name”: “customers”
},
“joins”: ,
“wheres”: {
“condition”: “AND”,
“rules”: [
{
“id”: “customers.idno”,
“field”: “customers.idno”,
“type”: “double”,
“operator”: “equal”,
“value”: null,
“data”: {
“table”: “customers”,
“column”: “idno”,
“type”: “number”
},
“operation”: “=”
}
],
“conditional”: null,
“valid”: true
},
“query”: “SELECT name\nFROM customers\nWHERE idno = :P1 /* */”,
“params”: [
{
“operator”: “equal”,
“type”: “expression”,
“name”: “:P1”,
“value”: null
}
]
},
“test”: true
},
“query”: “SELECT name
FROM customers
WHERE (idno
= ?)”,
“params”: [
{
“id”: “customers.idno”,
“field”: “customers.idno”,
“type”: “double”,
“operator”: “equal”,
“value”: null,
“data”: {
“table”: “customers”,
“column”: “idno”,
“type”: “number”
},
“operation”: “=”
}
]
}
}
Any suggestions would be most welcome.
Your server action is wrongly set up.
You should not be using the security provider step in the server action:
You need the security provider set up in the globals:
And the identity step:
which you then use to filter your query.
I had it in globals but I was not populating the list in server data bindings unless I added it in steps