Hi,
I've got 3 functions on 3 consecutive pages. Each function passes info onto the following page and asks more questions.
Question:
1. The variable $discountSelect only registers 1 on the next page... not the value that is assigned to it in the mysql table. They are all correct on page one, but on page 2 the companies are correct but the discount isn't.
2. going from page 2 to 3 I get an "Undefined Index" error for both $companySelect and $discountSelect. I think that this is a session error, the variables have ceased to exist, but I;m not sure.
Please can someone point me in the right direction, as after 3 days it's starting to get to me a little bit!
here are the functions:
function investment_list()
{
//list companies and % discount from db=client table company_list
$user="luds";
$host="localhost";
$password="";
$database="client";
$connection = mysql_connect($host,$user,$password) or die
("Couldn't connect to server!"
$db = mysql_select_db($database,$connection) or die ("Couldn't select database"
$query = "SELECT * FROM company_list ORDER BY companyName";
$result = mysql_query($query) or die ("couldn't execute."
?>
<table width="350">
<th width="70%" align="center">Company Name</th>
<th width="30%" align="center">Percentage Discount</th>
</table>
<form action='companyP2.php' method='POST'>
<?php
while ($row = mysql_fetch_array($result))
{
extract($row);
?>
<table width="350" bgcolor="#999999">
<tr>
<td width="70%">
<?php
echo "<input type='radio' name='companySelect' value='$companyName'>$companyName\n"; ?></td>
<td>
<?php echo "<input name='discountSelect' value='$discount'\n<br>"; ?></td>
</tr>
</table>
<?php
}
?>
<table>
<tr><td><input type="submit" value="Move to Step Two"></td></tr></table>
"</form>";
<?php
}
?>
<?php
function investment_amount()
{
?>
<table bgcolor="#ffffff">
<form method='post' action="companyP3.php">
<table bgcolor=#cccccc>
<tr>
<td align="center" colspan="2">
You have chosen the company <strong><?php echo $_POST['companySelect']; ?></strong>
</td></tr>
<tr>
<td align="center" colspan="2">
which has a discount at the moment of <strong><?php echo $_POST['discountSelect']; ?></strong> percent
</td></tr>
<tr><td colspan="2">
Amount you wish to invest = £ <input type=text name=sum_invested>
</td>
</tr>
<tr>
<td><input type="submit" value="Next Step"></td></tr>
</table>
<?php
}
?>
<?php
function display_registration_form2()
{
?>
<form method='post' action="register_new.php">
<table bgcolor=#cccccc>
<tr>
<td align="center" colspan="2">You have chosen to invest <strong>£<?php echo $_POST['sum_invested']; ?></strong>
in <strong><?php echo $_POST['companySelect']; ?></strong></td></tr>
<tr>
<td align="center" colspan="2">which has a discount at the moment of <strong>
<?php echo $_POST['discountSelect']; ?></strong> percent</td></tr>
<tr>
<td align="center">Please enter your personal details to submit this information</td></tr>
<tr>
<td>Email address:</td>
<td><input type=text name=email size=30 maxlength=100></td></tr>
<tr>
<td>Preferred username <br />(max 16 chars):</td>
<td valign=top><input type=text name=userName
size=16 maxlength=16></td></tr>
<tr>
<td>Password <br />(between 6 and 16 chars):</td>
<td valign=top><input type=password name=passwd
size=16 maxlength=16></td></tr>
<tr>
<td>Confirm password:</td>
<td><input type=password name=passwd2 size=16 maxlength=16></td></tr>
<tr>
<td>First Name:</td>
<td><input type=text name=firstName size=30 maxlength=100></td></tr>
<tr>
<td>Surname:</td>
<td valign=top><input type=text name=lastName size=16 maxlength=16></td></tr>
<tr>
<td>Address:</td>
<td valign=top><input type=text name=address size=16 maxlength=16></td></tr>
<td colspan=2 align=center>
<input type=submit value="Submit"></td></tr>
</table></form>
<?php
}
?>
Cheers
luds
I've got 3 functions on 3 consecutive pages. Each function passes info onto the following page and asks more questions.
Question:
1. The variable $discountSelect only registers 1 on the next page... not the value that is assigned to it in the mysql table. They are all correct on page one, but on page 2 the companies are correct but the discount isn't.
2. going from page 2 to 3 I get an "Undefined Index" error for both $companySelect and $discountSelect. I think that this is a session error, the variables have ceased to exist, but I;m not sure.
Please can someone point me in the right direction, as after 3 days it's starting to get to me a little bit!
here are the functions:
function investment_list()
{
//list companies and % discount from db=client table company_list
$user="luds";
$host="localhost";
$password="";
$database="client";
$connection = mysql_connect($host,$user,$password) or die
("Couldn't connect to server!"
$db = mysql_select_db($database,$connection) or die ("Couldn't select database"
$query = "SELECT * FROM company_list ORDER BY companyName";
$result = mysql_query($query) or die ("couldn't execute."
?>
<table width="350">
<th width="70%" align="center">Company Name</th>
<th width="30%" align="center">Percentage Discount</th>
</table>
<form action='companyP2.php' method='POST'>
<?php
while ($row = mysql_fetch_array($result))
{
extract($row);
?>
<table width="350" bgcolor="#999999">
<tr>
<td width="70%">
<?php
echo "<input type='radio' name='companySelect' value='$companyName'>$companyName\n"; ?></td>
<td>
<?php echo "<input name='discountSelect' value='$discount'\n<br>"; ?></td>
</tr>
</table>
<?php
}
?>
<table>
<tr><td><input type="submit" value="Move to Step Two"></td></tr></table>
"</form>";
<?php
}
?>
<?php
function investment_amount()
{
?>
<table bgcolor="#ffffff">
<form method='post' action="companyP3.php">
<table bgcolor=#cccccc>
<tr>
<td align="center" colspan="2">
You have chosen the company <strong><?php echo $_POST['companySelect']; ?></strong>
</td></tr>
<tr>
<td align="center" colspan="2">
which has a discount at the moment of <strong><?php echo $_POST['discountSelect']; ?></strong> percent
</td></tr>
<tr><td colspan="2">
Amount you wish to invest = £ <input type=text name=sum_invested>
</td>
</tr>
<tr>
<td><input type="submit" value="Next Step"></td></tr>
</table>
<?php
}
?>
<?php
function display_registration_form2()
{
?>
<form method='post' action="register_new.php">
<table bgcolor=#cccccc>
<tr>
<td align="center" colspan="2">You have chosen to invest <strong>£<?php echo $_POST['sum_invested']; ?></strong>
in <strong><?php echo $_POST['companySelect']; ?></strong></td></tr>
<tr>
<td align="center" colspan="2">which has a discount at the moment of <strong>
<?php echo $_POST['discountSelect']; ?></strong> percent</td></tr>
<tr>
<td align="center">Please enter your personal details to submit this information</td></tr>
<tr>
<td>Email address:</td>
<td><input type=text name=email size=30 maxlength=100></td></tr>
<tr>
<td>Preferred username <br />(max 16 chars):</td>
<td valign=top><input type=text name=userName
size=16 maxlength=16></td></tr>
<tr>
<td>Password <br />(between 6 and 16 chars):</td>
<td valign=top><input type=password name=passwd
size=16 maxlength=16></td></tr>
<tr>
<td>Confirm password:</td>
<td><input type=password name=passwd2 size=16 maxlength=16></td></tr>
<tr>
<td>First Name:</td>
<td><input type=text name=firstName size=30 maxlength=100></td></tr>
<tr>
<td>Surname:</td>
<td valign=top><input type=text name=lastName size=16 maxlength=16></td></tr>
<tr>
<td>Address:</td>
<td valign=top><input type=text name=address size=16 maxlength=16></td></tr>
<td colspan=2 align=center>
<input type=submit value="Submit"></td></tr>
</table></form>
<?php
}
?>
Cheers
luds