Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1016587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:34:16+00:00 2026-05-16T10:34:16+00:00

I’m trying to pass a value from a select input control on an HTML

  • 0

I’m trying to pass a value from a select input control on an HTML form.
When I hardcode it, it gets echoed, when not, all I get is this:
The invention type did not go through correctly.

Here is my page1.php:

<?php
session_start(); 

$_SESSION['invtype'] = $invtype;

$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];

if (isset($_POST['Submit'])) {

        if ($_POST['firstname'] != "") {
            $_POST['firstname'] = filter_var($_POST['firstname'], FILTER_SANITIZE_STRING);
            if ($_POST['firstname'] == "") {
                $errors .= 'Please enter a valid first name.<br/><br/>';
            }
        } else {
            $errors .= 'Please enter your first name.<br/>';
        }

        if ($_POST['lastname'] != "") {
            $_POST['lastname'] = filter_var($_POST['lastname'], FILTER_SANITIZE_STRING);
            if ($_POST['lastname'] == "") {
                $errors .= 'Please enter a valid last name.<br/><br/>';
            }
        } else {
            $errors .= 'Please enter your last name.<br/>';
        }

    if (!$errors) {header("location: offerform_switch.php");
       }


        else {
            echo '<div style="color: red">' . $errors . '<br/>
                </div>';



        }
    }

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title>Offer Form, Part 1</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <link rel="stylesheet" href="inventron_sage_short.css" type="text/css" />
        <link rel="stylesheet" href="form.css" type="text/css" />

    </head>
    <body>
        <div id = "logo">
            <img src = "img/top.jpg" alt = "logo" />
        </div>  
        <div id = "wrapper">




            <div id="stylized" class="myform">
<form id="form" action="page1.php" method="post">



    <p>
        <label for="firstname">FIRST NAME*:
        </label>
        <input type="text" name="firstname" id="firstname" value="<?php echo $firstname?>" />
    </p>    

    <p>
        <label for="lastname">LAST NAME*:
        </label>
        <input type="text" name="lastname" id="lastname" value="<?php echo $lastname?>" />
    </p>    

    <div id = "category">Categorize your invention:</div>

<div class="spacer"></div>

    <p>
        <select  id="invtype" name="invtype">
            <option value="0" selected="selected">Select type</option>
            <option value="product">PRODUCT</option>
            <option value="software">SOFTWARE</option>

        </select>
        <input type="submit" name="Submit" value="Next!" />

    </div>
      </div>
    </body>
</html>

Here is my offerform_switch.php:

<?php

session_start(); 
// echo variable from the session, we set this on our other page 
echo $_SESSION['invtype'];
$invtype = $_SESSION['invtype'];

//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("mysql.myserver.com","myuser","mypassword"); //(host, username, password)

//specify database ** EDIT REQUIRED HERE **
mysql_select_db("invention") or die("Unable to select database"); //select which database we're using


switch ($invtype){
    case "product":
        include("page2_product.php");
        break;
    case "software":
        include("page2_software.php");
        break;
    default:
       echo "The invention type did not go through correctly."; 
}

?>

What am I doing wrong?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:34:17+00:00Added an answer on May 16, 2026 at 10:34 am

    It should be

    $_SESSION['invtype'] = $_POST['invtype'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I'm trying to select an H1 element which is the second-child in its group
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.