开发者

How can save (multiple) entries from a html form to an array in php?

I have an HTML form with three fields, first name surname and mid. name and I want to save this information in a php page. The problem is I don't know how to save multiple entries in array without a connection of database.

HTML form

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">开发者_如何学Python
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Εργασία 11 - Βασίλης Τρίγκας</title>
    </head>
    <body>
        <h4>Καταχώριση βιβλίου</h4>
        <form action="form_action.php" method="get">
            Συγγραφέας <br/><input type="text" name="fnwriter" /><br/>
            Τίτλος <br/><input type="text" name="title" /><br/>
            Εκδότης<br/> <input type="text" name="editor" /><br />
            <input type="submit" value="Submit" />
        </form>

    </body>
</html>

PHP File

    <?php 

function display_welcome(){
    print("Σωστή εισαγωγή,  ");
    print($_GET['fnwriter','title','editor'])
}

function display_empty_form(){
    print <<<_HTML_
    <FORM method="post" action="$SERVER['PHP_SELF']">
    <BR/>
    <INPUT type="submit" value="SUBMIT NAME">
    </FORM>
    _HTML_;
}

if ($_GET['fnwriter','title']) {
    display_welcome();
}
else {
    display_empty_form();
}

$Book=array("fnwriter","title","editor");

$fwriter=$_GET['$fnwriter']
$title=$_GET['$title']
$editor=$_GET['$editor']

echo $fnwriter;
echo $title;
echo $editor;

for ($i = 0; $i < count($fnwriter,$title,$editor); ++$i) {
        echo "Book $i= $fnwriter[$i],$title[$i],$editor[$i]<br />";
    }

//echo $Book[$_GET];
//print_r($);
?>


I don't really get your question, is that about saving data to a file, or about processing $_POST data?

If it's the first one, you have a plenty of possibilities, from simple CSV (or any other separator) to XML ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜