I have been searching for an answer to this for the last two days.
I am trying to add a list of manufacturers to an existing form in php.
This worked out ok and I got it to work somewhat.

Here is the problem when the user makes the selection and submits the form
it takes them to another page that shows them a preview of their post.
In this preview it show them the manufacturer they selected. But when they finalize the the
post it doesn't show using the same code.

I know that their must be a simple way of doing this. I am not great with php but I have put forth a valiant effort to get this done. I am stumped please help.

Here is my code.

HTML:

<select action="select.php" name="manufacturer">
		<option value="Lincoln">Lincoln</option>
		<option value="Example">Example</option>
		</select>

PHP:

<?php
    if(isset($_POST['manufactuer']))
    echo "Manufacturer: ".$_POST['manufacturer'];
      else {?>

I call to the selection with this.

<?php echo "Manufacturer: ".$_POST['manufacturer']; ?>

How do I show this when the user posts and if the same user posts again or a different user posts to show their selections for those specific posts.
posts

Do you mean that when the user posts the second form, the variable isn't submitted again? i.e. Your user posts the manufacturer, is brought to a list of products, and when they post from there the manufacturer isn't in the second post?

If so, you should either use php sessions to store data (a little difficult if you are just modifying) or echo the manufacturer to a hidden text input field which will post from the second page, that way the user can't see it, but it still submits.

Hope it helps:
- Joe

Do you mean that when the user posts the second form, the variable isn't submitted again? i.e. Your user posts the manufacturer, is brought to a list of products, and when they post from there the manufacturer isn't in the second post?

If so, you should either use php sessions to store data (a little difficult if you are just modifying) or echo the manufacturer to a hidden text input field which will post from the second page, that way the user can't see it, but it still submits.

Hope it helps:
- Joe

Well basically this is what I need. The user makes a selection that selection is stored and displayed on two pages the the preview page and the post page. I need it displayed on the post page permanently for anyone who comes on the site and views that post to see. I need this to be same for any user who submits a post.

In that case, you probably want to store the data in a database, and fetch it for the page when other users come to see it. The post page would just have to store it in the database. To differentiate your display pages from one another, I'd recommend adding a GET parameter to help the page find the right record in the database:

i.e.
Database:

ID, MFR, INFO
1, Lincoln, A good car
2, Example, A better car

Then, in your view post page, you could use a param like id:

view_post.php?id=1

which would run a sql command like:

SELECT * FROM cars WHERE ID=1;

and you could then use PHP to echo information to the page.

I'm not sure how to do this. I tried to look up a way and there are different ways and it seems confusing. How would I convert my current list to insert into the database

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.