Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


12,834 Points

Problem with page count variable type in $_POST

Alright, so I think my trouble is coming from variable type possibly. I've been trying to get my page number to increment when an answer is picked, but I'm messing something up. My hunch is that it's something simple, but I can't figure it out.

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <title>Math Quiz: Addition</title>
    <link href='https://fonts.googleapis.com/css?family=Playfair+Display:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/styles.css">
    if (isset($_POST['page'])){
/// yes, I know I should sanitize the input, I was just trying different things to figure this out.
        $q_num = (int)$_POST['page'];
    } else {
    $q_num = 1;
$p_num = 10;

<?php var_dump($q_num);?>
    <div class="container">
        <div id="quiz-box">
            <p class="breadcrumbs">Question #<?= $q_num;?> of <?= $p_num;?></p>
            <p class="quiz">What is <?php 
            ?> </p>
            <form action="index.php" method="POST">
                <input type="hidden" name="page" value="<?php ($q_num+1);?>" />
                <input type="submit" class="btn" name="answer" value="135" />
                <input type="submit" class="btn" name="answer" value="125" />
                <input type="submit" class="btn" name="answer" value="115" />