Simple form which automatically inputs data depending on various buttons clicked...

TheFakeMoonMan

New Member
Hey,

I've been charged with developing a website for my internship. However...I only know basic HTML/CSS and no scripting. In fact, to give you a better idea of how limited my knowledge is, I don't even know if what I call 'scripting' is what scripting really is...

ANYWAYS...The website I made is basically set up in such a way so he can advertise products and customers can use a form to request a quote on the item.

Each item page has a button on it that reads 'get quote' and links to the form which they can fill out and will be e-mailed to my boss. With this setup, all of the items will be linking to the same form and they would be required to input a product number into the form so my boss knows which item they're interested in.

Is there any (fairly simple) way to create a system where a specific product number would be entered into the form automatically depending on which button they click?

Here is a sample of what I'm working with: http://www.jazzachinos.com/website/trophies_awards/acrylics/products/ahi-cb/index.html

Again, if I had the time or knowledge how to create a database, I would do it...so hopefully there is a simpler alternative.

Thanks so much! This has been driving me crazy.
 
Last edited:

Denno

New Member
Here is how you can do it:

Test Page:
HTML:
<body>
<p><a href="form.php?item=001">Item 1</a></p>
<p><a href="form.php?item=002">Item 2</a></p>
<p><a href="form.php?item=003">Item 3</a></p>
</body>

php script:
PHP:
<?php
$item = $_GET['item'];

if($item == "001"){
	echo "You have selected item 1";
}else if($item == "002"){
	echo "You have selected item 2";
}else if($item == "003"){
	echo "You have selected item 3";
}else{
	echo "You have selected an invalid item";
}
?>

I have simply used the GET method to pass the item ID from the items page, to the form page. Instead of echoing this out like I have here, you just feed this into the form. I'm assuming that it doesn't matter if the user see's the item id. You'll also notice that I added the extra else at the end so that if a user wants to change the item id in the address bar themselves, it will show an invalid id (provided they change it to an ID that isn't already there).

I know you posted this a while ago, but I hope it can help :).

Denno
 
Top