1

I've been working on this problem way too long, and I'm getting nowhere. So please excuse what might be a vague question.

Basically, I've created what I think is a modular website, using php and html. I have an index.php page, which 'include's header.php, footer.php, and then in the middle, a content.php page based on 'case' statements in index.php. There are several choices for the content page, but I'll only mention content.php for now.

And here's the problem: content.php has a form, whose 'action' is content.php (with method = post), which is the file located in my web directory, and not the included file. When I hit 'submit', I need the processed form to come up in the included content.php file, displayed with header.php and footer.php, but it just goes to the isolated file on the server.

Any suggestions on a new approach? Thanks!

1 Answer 1

3

Set the action to point to the file that includes content.php.

You seem to have basically this:

index.php:

<?php
    include('header.php');
    switch($_GET['a']){
        case 'foo':
            include('content1.php');
            break;
        case 'bar':
            include('content2.php');
            break;
        default:
            include('default.php');
            break;
    }
    include('footer.php');
?>

Then your action points to index.php?a=foo, not, say, content1.php.

Sign up to request clarification or add additional context in comments.

3 Comments

Well I don't know how, and I don't know why, but that worked. It's way past my bedtime, and my brain has stopped working, so I'll figure it out in the morning. Thanks, Mark!
@Reg H, it really is fairly simple, the action tells the form where to go, and as you said in your post, you want it to go to your main page, not to content.php, so now you're telling it to go to the main page... :)
Right you are... I was making it too complicated. Thanks again.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.