php and forms

This is a discussion on php and forms within the alt.comp.lang.php forums, part of the PHP Programming Forums category; hi can PHP be used to do CGI functions on say forms, I know it can use databases like mysql. ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-14-2004
john townsley
 
Posts: n/a
Default php and forms

hi

can PHP be used to do CGI functions on say forms, I know it can use
databases like mysql.
for eg a simple form which asks for users name and comments , the details to
be stored on a simple text file


Reply With Quote
  #2 (permalink)  
Old 06-14-2004
Alvaro G Vicario
 
Posts: n/a
Default Re: php and forms

*** john townsley wrote/escribió (Mon, 14 Jun 2004 21:07:04 +1000):
> can PHP be used to do CGI functions on say forms, I know it can use
> databases like mysql.
> for eg a simple form which asks for users name and comments , the details to
> be stored on a simple text file


Not sure of what you mean. You don't need to mix up CGI and PHP to write a
guestbook. You can write a CGI-only or a PHP-only solution.

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Reply With Quote
  #3 (permalink)  
Old 06-14-2004
Steven Stern
 
Posts: n/a
Default Re: php and forms

On Mon, 14 Jun 2004 21:07:04 +1000 (more or less), "john townsley"
<johntownsley@optusnet.com.au> wrote:

>hi
>
>can PHP be used to do CGI functions on say forms, I know it can use
>databases like mysql.
>for eg a simple form which asks for users name and comments , the details to
>be stored on a simple text file
>


<?

/* records form response to file
form contains two fields, "name" and "comments".
*/

if (!(isset($_POST[submit]))):
{
$fname = "/path/to/file.txt";
$file = fopen($fname,"a+") or die("file open failed");
$data=array($_POST['name'],$_POST['comments']);
$content=makeCSV($data)
$content.="\n";
fwrite($file,$content) or die("fwrite failed");
fclose($file);
}
/*---
makeCSV

Given an array of string data, returns a single string with each element
quoted and
separated by commas

---*/

function makeCSV($data)
{
$sep = '","';
if(!is_array($data)) { return ''; }
$ret = '';
foreach($data as $record)
{
$ret = $ret.$sep.$record;
}
// strip off leading sep and add closing quote
$ret = substr($ret,2).'"';
return $ret;
}
?>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:08 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0