0

Like the title says, I'm having a hard time getting the printf() and echo parts of my code to output their text properly.

Here's the first page, a simple form:

<form action="WhoYouAre.html" method="post">
        <Label>Name: <label><input type="text" name="name"><br>
        <Label>Age: <label><input type="text" name="age"><br>
        <Label>Address: <label><input type="text" name="address"><br>
        <Label>State: <label><input type="text" name="state"><br>
        <Label>Sex: <label><input type="text" name="sex"><br>
        <input type="submit" value="Submit">
    </form>

And here's the code for the page that's supposed to display the information:

<?php
    session_start(); ?>
    <?php
    $_SESSION['name'] = $_POST['name'];
    $_SESSION['age'] = $_POST['age'];
    $_SESSION['address'] = $_POST['address'];
    $_SESSION['state'] = $_POST['state'];
    $_SESSION['sex'] = $_POST['sex'];

    printf("Your name is %s.
    Your age is %d.
    Your address is %s, in the state of %s.
    Your gender is %s.", $_SESSION['name'], $_SESSION['age'],
    $_SESSION['address'], $_SESSION['state'], $_SESSION['sex']);

    if($_SESSION['sex'] == 'male')
        echo "<body style='background: url(http://images.mentalfloss.com/sites/default/files/styles/article_640x430/public/4hjh3kj634.png)'>";

    echo file_get_contents("PostPage.txt");
    ?>

Here's what is output to my page.

"; echo file_get_contents("PostPage.txt"); ?>

Any tips??

Qirel
  • 25,449
  • 7
  • 45
  • 62
Diszy1
  • 1

1 Answers1

0

You are posting your form to a .html file:

<form action="WhoYouAre.html" method="post">

While it can be set, by default .html files are not parsed and executed as PHP source files, so it will return its content unmodified. You will need to use the .php extension instead.

Zoli Szabó
  • 4,366
  • 1
  • 13
  • 19