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 8426259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:29:51+00:00 2026-06-10T04:29:51+00:00

In simple terms I have a form which has three identical entry fields. The

  • 0

In simple terms I have a form which has three identical entry fields. The names are different; however, when posted they have the same structure just different name prefix (ie three systems have different name prefixes: they would be windowstitle, mactitle, linuxtitle etc).

Currently I have a process that will only work one namesake out ie windowstitle (if the form is filled out, of course)

The code looks something like this:

<?php
$title = $_POST['windowstitle'];
//validate info or redirect
if ($title != "" ) {
    $title = mysql_real_escape_string($title);
    $sql = "insert into newwindows (title) values ('$title');
    $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());
?>

Also the form block looks something like this

<form action="newuserprocess.php" method="post" enctype="multipart/form-data">
<div class="form">
    <h3>Windows</h3>

    <!-- title of system name -->
    <p><label for="windowstitle"> edition of system </lable></p>
    <input type="text" name="windowstitle"  size=20 /><br />
    </div>
    <div class="form">
    <h3>Mac</h3>

    <!-- title of system name -->
    <p><label for="mactitle"> edition of system </lable></p>
    <input type="text" name="mactitle"  size=20 /><br />
    </div>
<p><input type="submit" id="submit" class="bigbutton" value="Upload" /></p>
</form>

However, that leaves other forms left out with the only difference being the db I wanted entered and the post value prefix different.

So I came up with what I thought was a clever solution:

<?php
$arr = array('windows', 'mac', 'linux');
foreach ($arr as &$value) {
    $title = $_POST['$valuetitle'];
    //validate info 
    if ($title != "" ) {
        $title = mysql_real_escape_string($title);
        $sql = "insert into new$value (title) values ('$title');
        $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());
    }
?>

However, this does not work. I know partly why; because '' makes the variable appear as is, thus my $_Post will always come back as $value. Another reason is the same with my new$value database name. What is the proper format for this? How do I make this work?

  • 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-06-10T04:29:52+00:00Added an answer on June 10, 2026 at 4:29 am

    you probably want

    $title = $_POST[$value . 'title'];
    

    and

    $sql = "insert into new$value (title) values ('$title')";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple web form which consists of labels and input fields,
I have a simple form which works as intended. It is a multi-step form
i have a php dynamic website with a simple mysql search form which means
I have a listview, which is used as an index to a simple search
I have a registration form which contains a read-only textarea. I want to require
Simple problem here (I think). I have a form with a checkbox at the
I have a simple search bar, user types in a search terms and tweets
In an open source project I maintain, we have at least three different ways
I have a very simple script: #!/bin/bash gnuplot << EOF set term postscript portrait
Can someone explain ProxyFactoryBean in simple terms? I see this being quoted lot of

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.