10-07-2018, 12:52 PM
Hi Folks,
I have created form using form builder and this form has to be accessed by the users without login and submit the form and the same has to be saved inside the db but so far its not happening.
form posting php as follows i.e. abc.php
<?php require_once './users/init.php'; ?>
<?php require_once $abs_us_root.$us_url_root.'users/includes/header.php'; ?>
<?php require_once $abs_us_root.$us_url_root.'users/includes/navigation.php'; ?>
<?php if (!securePage($_SERVER['PHP_SELF'])){die();} ?>
<div id="page-wrapper">
<div class="container">
<?php
if($_POST){
//print_r($_POST);exit;
$db = DB::getInstance();
[font=Droid Sans Mono]
try {
// echo "Trying to create user";
$fields=array([/font]
[font=Droid Sans Mono][font=Droid Sans Mono] 'var1' => Input::get('[font=Droid Sans Mono]var1'),
'var2' => ucfirst(Input::get('var2')),
'var3' => Input::get('var3'),[/font][/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono] );
print_r($fields);
var_dump($db);
$db->insert('tablename',$fields) or die("not able to create record");exit;
$theNewId=$db->lastId();[/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono]}[/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono][font=Droid Sans Mono]displayForm('abcform');[/font][/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono]abc.php has be defined as public and error I am getting as follows[/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono]object(DB)#8 (9) { ["_pdo":"DB":private]=> object(PDO)#6 (0) { } ["_query":"DB":private]=> object(PDOStatement)#32 (1) { ["queryString"]=> string(50) "SELECT id, page, private FROM pages WHERE page = ?" } ["_error":"DB":private]=> bool(false) ["_errorInfo":"DB":private]=> array(3) { [0]=> int(0) [1]=> NULL [2]=> NULL } ["_results":"DB":private]=> array(1) { [0]=> object(stdClass)#31 (3) { ["id"]=> string(2) "87" ["page"]=> string(14) "abc.php" ["private"]=> string(1) "0" } } ["_resultsArray":"DB":private]=> array(1) { [0]=> array(3) { ["id"]=> string(2) "87" ["page"]=> string(14) "abc.php" ["private"]=> string(1) "0" } } ["_count":"DB":private]=> int(1) ["_lastId":"DB":private]=> string(1) "0" ["_queryCount":"DB":private]=> int(51) } not able to create record[/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono]I am struck here please someone help me[/font][/font]
I have created form using form builder and this form has to be accessed by the users without login and submit the form and the same has to be saved inside the db but so far its not happening.
form posting php as follows i.e. abc.php
<?php require_once './users/init.php'; ?>
<?php require_once $abs_us_root.$us_url_root.'users/includes/header.php'; ?>
<?php require_once $abs_us_root.$us_url_root.'users/includes/navigation.php'; ?>
<?php if (!securePage($_SERVER['PHP_SELF'])){die();} ?>
<div id="page-wrapper">
<div class="container">
<?php
if($_POST){
//print_r($_POST);exit;
$db = DB::getInstance();
[font=Droid Sans Mono]
try {
// echo "Trying to create user";
$fields=array([/font]
[font=Droid Sans Mono][font=Droid Sans Mono] 'var1' => Input::get('[font=Droid Sans Mono]var1'),
'var2' => ucfirst(Input::get('var2')),
'var3' => Input::get('var3'),[/font][/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono] );
print_r($fields);
var_dump($db);
$db->insert('tablename',$fields) or die("not able to create record");exit;
$theNewId=$db->lastId();[/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono]}[/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono][font=Droid Sans Mono]displayForm('abcform');[/font][/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono]abc.php has be defined as public and error I am getting as follows[/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono]object(DB)#8 (9) { ["_pdo":"DB":private]=> object(PDO)#6 (0) { } ["_query":"DB":private]=> object(PDOStatement)#32 (1) { ["queryString"]=> string(50) "SELECT id, page, private FROM pages WHERE page = ?" } ["_error":"DB":private]=> bool(false) ["_errorInfo":"DB":private]=> array(3) { [0]=> int(0) [1]=> NULL [2]=> NULL } ["_results":"DB":private]=> array(1) { [0]=> object(stdClass)#31 (3) { ["id"]=> string(2) "87" ["page"]=> string(14) "abc.php" ["private"]=> string(1) "0" } } ["_resultsArray":"DB":private]=> array(1) { [0]=> array(3) { ["id"]=> string(2) "87" ["page"]=> string(14) "abc.php" ["private"]=> string(1) "0" } } ["_count":"DB":private]=> int(1) ["_lastId":"DB":private]=> string(1) "0" ["_queryCount":"DB":private]=> int(51) } not able to create record[/font][/font]
[font=Droid Sans Mono][font=Droid Sans Mono]I am struck here please someone help me[/font][/font]