Search code examples
phphtmlformsmultipart

Create multipart form & redirect user


I am fairly new to web design and need some help coding a form. What I am looking to do is take an HTML form that contains a birthday drop down section (mm/dd/yyyy - So 3 different select tabs) and redirect a user based on their age.

If the user is under 30 send them to a new page that says we can't help them. If the user is 30 or over, send them to a second form where they will be able to answer follow up questions... so another form. When processed, I would need to display all the data the user has entered from the beginning of the process.

It's basically 2 form pages, and the 2nd only appears if the user is 30 or over. I am trying to code this using PHP and can't seem to get started. Any help would be appreciated.

Thanks!!


Solution

  • $interval = date_diff(new DateTime(), new DateTime($_POST['year'] .'-'. $_POST['month'] .'-'. $_POST['day']));
    
    if ($interval->y >= 30)
    {
        session_start();
        $_SESSION = $_POST;
        header('Location: over30.php');
    }
    else
    {
        header('Location: under30.php');
    }
    

    in the next form...

    <?php session_start(); ?>
    
    <html>
        <head><head>
        <body>
            <form method="post" action="xxx.php">
                <input type="text" value="<?=$_SESSION['name'];?>" />
            </form>
        </body>
    </html>