mercredi 29 avril 2015

How can I save data from a html form in a file? [duplicate]

This question already has an answer here:

I did the simple form.In that i am trying modifying the $_post output.

<?php

    $lhs = array();
    $rhs = array();

    foreach($_POST as $key => $value) {
        echo $key . "=" . $value;
        echo "<br>";
        $lhs[] = $key; //first array for left hand side 
        $rhs[] = $value; //second array for right hand side

    }

?>

<form name="form1" method="post" action="">
    Name: <input type="text" name="name"><br>
    Phone No: <input type="text" name="phone" /><br/>
    Course:<input type="text" name="course" /> <br />
    <input type="submit" name="Submit" value="Sign Up">
</form>

So the output of this could be:

name=xyz
phone=123455453
course=be
Submit=Sign Up

now you can observe see that I am getting the output of the button also:

Submit=Sign Up

Which I don't require in the output. And I require the output something like this:

name=xyz
phone=123455453
course=be

This output I want to store in a text file.

I am not able to modify the output either I am not able to store this output in a text file.

How can I get rid of the submit button output and save the data into a file?

Any Help or advice is appreciated and Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire