CMSimple <--> MySQL Database Connection

originated from the CMSimple Forum

An extensive explanation of this method can be found at Personalized Reply Page. It just misses the CMSimple-MySQL link. Otherwise, it uses the same method.

Project:

Call an application form which writes its data to a MySQL database. A reply page should be opened up in CMSimple which says “Thank you” and shows all the data once more, the applicant has just entered.

Solution:

Call a form page via the geturl() script. The form is introduced with:

<form name="Formular" action="./?Your_Application" method="POST">

“Your Application” is a hidden page which has to be generated. It is empty except for the CMSimple script to hide (#CMSimple hide#). In order to process the query just one line of code has to be added to the template.htm file.

<?=editmenu()?>
<?=content()?>
<?php if($u[$s]=='Your_Application'){include($pth['folder']['base'].'/handover.php');} ?>
<?=submenu()?>

Where you put the CMSimple content() function you just add this line of code, too. It makes sure that the call for “Your Application”, which is done by the form, hands over the data (or variables) to the “handover.php” file which does all the job - writing the data to the MySQL database and giving back the data to the hidden page (“Your_Application”). This hidden page finally turns up for the viewer. That's all. No other changes have to bemade.

You can place additional form pages and do queries, as well, by just adding more lines to the content.htm file. So you could add login procedures, questionaries, database queries - which get their own hidden page and their own single lines of code in the template.


Discussion

Allan Thulstrup, 2008/04/17 00:14

As a newbee it would be nice with small examples of the functions you use this method for; ‘handover.php’ file, a file for the use af a login and a file for doing queries. Regards Allan

Tillman Schuster, 2008/04/17 07:05

I think, this does not make very much sense, since this is a normal PHP file writing to a database and reading it out again. This file itself wont work. You need a MySQL database and the whole setup to make it work. If you want to generate such files, check http://phpformgen.sourceforge.net/

However, there is a second desription at: http://www.cmsimplewiki.com/doku.php/tips_and_tricks/personalized_reply_page which uses the same techique but omits the MySQL-database. This description comes with an example to download. If you test this, it will become more comprehensible to you, how it works altogether in conjuction with a databse.

tips_and_tricks/cmsimple_and_mysql.txt · Last modified: 2009/12/03 18:56 (external edit)
Webdesign: NMuD chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0