Forum Moderators: coopster
The page currently uses static submit buttons with a value and id equal to the product people want to buy. It is session based and, based on the value, moves on to the next page.
We have added more options and, instead of polluting the page with unnecessary information, I wanted to add dropdown select fields.
The following is a snipit from the page:
...
if($_POST['1_x'])
{
$_SESSION['temp_pack'] = "1";
header("Location:../register/index.php");
}
...
<form name="frm" id="frm" method="post" action="select.php">
...
<select name="Package">
<option value="">Selecta Package</option>
<option value="1">1st Package</option>
<option value="2">2nd Package</option>
<option value="3">3rd Package</option>
</select>
...
This is the static link to the 1st package that will let you continue:
<input type="image" name="1" src="/templates/<?php echo TEMPLATEDIR; ?>/images/select.png"">
How can I populate name in the input tag with the value from the options?
Any help would be appreciated as I know next to nothing about html and php.
This is the first page of an order process. I've been able to change and add a few packages in the past, but the page is getting to be a mess. Each current package is a small graphic with an input image below it - <input type="image" name="(package number 1-11 goes here)" src="/templates/<?php echo TEMPLATEDIR; ?>/images/select.png"">
I'm trying to change it so that a user can select from a dropdown menu but the original coder used the name field in the input to pass the package number to the session.
When I replaced name="1" with name=$_POST['Package'] it returns to the same page.
I tried changing the values to N_x (see below) but it still doesn't go forward. Let me know if I can provide any further information that may make it clearer. Thanks!
More on the session info:
session_start();
if ($_SESSION['usi']!="")
header("Location: /index.php");
else
$_SESSION['usi']="";
$dbObj = new Database();
$dbObj->connect_db();
$fnObj = new Functions();
$_SESSION['step1'] = "step1";
$_SESSION['select_posts'] = "";
$fnObj->csth(true);
extract($_POST);
//print_r($_POST);
if($_GET['temp_pack'])
{
$_SESSION['temp_pack'] = $_GET['temp_pack'];
header("Location:../register/index.php");
}
if($_POST['1_x'])
{
$_SESSION['temp_pack'] = "1";
header("Location:../register/index.php");
}
elseif($_POST['2_x'])
{
$_SESSION['temp_pack'] = "2";
header("Location:../register/index.php");
}
elseif($_POST['3_x'])
{
$_SESSION['temp_pack'] = "3";
header("Location:../register/index.php");
}
I'm trying to change it so that a user can select from a dropdown menu but the original coder used the name field in the input to pass the package number to the session.
If I understand you correctly, you need to make the <option> value now what used to be the <input> name attribute and modify your server-side code to use the option value returned to populate your SESSION data.
print '<pre>';
print_r($_POST);
print '</pre>';
exit;