2

I have 2 files : index.php, form.php.

form.php:

<?php

if (isset($_POST['submit'])){
    echo "OK";
    // do something with post data

}

?>
    <form method="post" name="myform">
        <input type="text" name="name" />
        <input type="submit" name="submit" value="SUBMIT" />
    </form>

I call form.php by typing in browser address bar: **mysite/index.php?act=form**

In index.php I have these line:

    <?php

    switch($_REQUEST['act']){
        case "form":
            include("form.php"); break;

    }
...

But I had nothing (in form.php) when the form was submitted. All that I want is get posted data in form.php, not in index.php.

What was I wrong here?

Thansk for your time!

2 Answers 2

7

change your line in form.php

<form method="post" name="myform" action="form.php">

or

<form method="post" name="myform" action="index.php?act=form">
Sign up to request clarification or add additional context in comments.

3 Comments

@quangtruong1985, glad to help you. If this solution helped you please mark this as a accepted solution so that others will know that the problem has been solved.
You got it. I have to wait for 5 minutes to mark your answer as accepted (just dont know why I have to).
@Sabin +1 fore being 1 sec ahead of xdazz ;)
2

So you need add the action attribute of the form:

<form action="/index.php?act=form" method="post" name="myform">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.