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??