posting data to the db publically...?

15 posts by 4 authors in: Forums > CMS Builder
Last Post: March 31, 2009   (RSS)

Re: [HDLLC] posting data to the db publically...?

By Dave - March 11, 2009

Hi Jeff,

Yes, that's all possible. With some of it requiring some custom programming.

For the first part, I've added a sample "Add Form" that will allow users to add data to the CMS Builder databases. This would make a good starting point for what you need.

See what you can do with that and let me know if you have any more questions. Also, we have consulting services available if you want a quote on some custom programming.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com
Attachments:

addform_004.php 3K

Re: [Dave] posting data to the db publically...?

By HDLLC - March 11, 2009

Thanks Dave!

Much appreciated - I'll use this to get started on just having a visitor add a record, in this case - a request for a specific item. That way, the site admin can search for those looking for something like that once it comes in - kind of like someone searching for a specific car. Let's them search for their visitors looking to buy something like that when it arrives.

Question though - how do I go about mapping this to a specific field I create in the database (using the CMS admin)...?

<textarea name="content" cols="30" rows="4"><?php echo htmlspecialchars(@$_REQUEST['content']) ?></textarea>

Alter the ['content'] portion to reflect the field I am referencing?

Thanks!

--Jeff

Re: [Dave] posting data to the db publically...?

By HDLLC - March 11, 2009

Also Dave - specifically, on this post your own classifieds question, isn't there a 'canned' add-on or solution download for the realty manager product? Trying to do the same here - but I can work on adding in a section for the paypal portion and manually create accounts or something... Looking for that one piece that maybe gets me 60% or more there - and I can poke around and maybe get the other 30-40% custom coded.

Make sense?

Thanks!

--Jeff

Re: [HDLLC] posting data to the db publically...?

By Dave - March 11, 2009

Hi Jeff,

>Alter the ['content'] portion to reflect the field I am referencing?

Yes, that's exactly it.

And for the classified system, I had a sample "user signup" form I can give you. It will need some minor modifications just as the other script, though.

Let me know if you want that.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] posting data to the db publically...?

By HDLLC - March 11, 2009

Hi Dave!

Thanks a million!

Bring it on! Would love to have that too!

Thanks!

--Jeff

Re: [HDLLC] posting data to the db publically...?

By Dave - March 11, 2009

Sure, here it is (attached).

And if you get an error that mysql_select_count_from () is missing add this to the bottom of /lib/database_functions.php

//
function mysql_select_count_from($tableName, $whereClause = '') {
if (!$tableName) { die(__FUNCTION__ . ": No tableName specified!"); }

$tableNameWithPrefix = getTableNameWithPrefix($tableName);
$escapedTableName = mysql_real_escape_string( $tableNameWithPrefix );
if ($whereClause != '') { $whereClause = "WHERE $whereClause"; }

$query = "SELECT COUNT(*) FROM $escapedTableName $whereClause";
$result = @mysql_query($query) or die(__FUNCTION__ . "() MySQL Error: ". htmlspecialchars(mysql_error()) . "\n");
list($recordCount) = mysql_fetch_row($result);
if (is_resource($result)) { mysql_free_result($result); }

//
return $recordCount;
}


Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com
Attachments:

usersignup.php 5K

Re: [Dave] posting data to the db publically...?

By s2smedia - March 30, 2009

can you show me a quick example of what i need to change in the code?

I keep getting a fatal error.. Here is just a test i was trying to get it to work with:


<?php
require_once "admin/lib/init.php";

// submit form
if (@$_REQUEST['submit']) {

// error checking
$errorsAndAlerts = "";
if (!@$_REQUEST['title']) { $errorsAndAlerts .= "Please specify title!<br/>\n"; }
if (!@$_REQUEST['content']) { $errorsAndAlerts .= "Please specify content!<br/>\n"; }

// turn off strict mysql error checking for: STRICT_ALL_TABLES
mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)

// add record
if (!@$errorsAndAlerts) {
mysql_query("INSERT INTO `{$TABLE_PREFIX}client_list` SET
title = '".mysql_real_escape_string( $_REQUEST['contact_name'] )."',
content = '".mysql_real_escape_string( $_REQUEST['company_name'] )."',

createdDate = NOW(),
updatedDate = NOW(),
createdByUserNum = '0',
updatedByUserNum = '0'")
or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
$recordNum = mysql_insert_id();

// display thanks message and clear form
$errorsAndAlerts = "Thanks, we've added that record!";
$_REQUEST = array();
}

}

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
body, td { font-family: arial }
</style>
</head>
<body>

<form method="post" action="">
<input type="hidden" name="submit" value="1" />

<h1>Sample Record Add Form</h1>

<?php if (@$errorsAndAlerts): ?>
<div style="color: red; font-weight: bold; font-size: 16px;"><br/>
<?php echo $errorsAndAlerts; ?><br/><br/>
</div>
<?php endif ?>


<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td valign="top">Title</td>
<td><input type="text" name="title" value="<?php echo htmlspecialchars(@$_REQUEST['contact_name']) ?>" size="30" /></td>
</tr>
<tr>
<td valign="top">Content</td>
<td><textarea name="content" cols="30" rows="4"><?php echo htmlspecialchars(@$_REQUEST['company_name']) ?></textarea></td>
</tr>
</table><br/><br/>


<input type="submit" name="add" value="Add Record &gt;&gt;" />

</form>
</body>
</html>

Re: [s2smedia] posting data to the db publically...?

By Dave - March 30, 2009

What's the error you're getting?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] posting data to the db publically...?

By s2smedia - March 30, 2009

Fatal error: Call to undefined function mysqlStrictMode() in XXXXXXX/addForm.php on line 13