Jump to content

[SOLVED] Form post problem multiple looping check box arrays


johlwiler

Recommended Posts

Ok I am almost giving up on this script. This is the first time I haven't been able to find my answers or ways to check my problem out. This script is being used as the starting of a payment module where people view the page it shows them their properties which are gotten from a database. That works. Then I have the user select check boxes and for which properties and how long they want to pay for. That gets posted back to the same php file. When I post back though everything stops. I don't get a timed out error, or a php error. Just a blank screen. I have tried multiple browsers, and multiple computers. I am looking for a reason and something I can change to get it up and going past that point. If know one knows of a way I am looking at maybe going in at a different approach. I am trying to save all propIDs all the way through the process so I can submit them with the payment. This is my first time using check boxes and arrays from check boexs in the manor I am doing. I have been going around and around in circles with this page and have had nothing but a hard time with it. My head is spinning.

 

well here is the code, I think I also attached it.

 

<?php @session_start(); ?>
<?php
//get userid needed ad so on
$loginID=$_SESSION['loginID'];
$username=$_SESSION['username'];

//checks to see if the user is logged in
if(!isset($_SESSION['loginID'])){
die ("You either are not logged in or you do not have permission to view this page you must log in. If you feel this is a mistake click here to <a href='../logout.php'>log out</a> and then immediatly log back in and try agian.");
}

include("../constents.php");





if(!isset($_POST['post']))
{
mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql' . mysql_error());

//search the database to see properties that need to be paid for
$sql="SELECT * FROM ".$dbname.".tbl_props WHERE LoginID='".$loginID."' and userdeactive='0'";
$result=mysql_query($sql);
$numberProps=mysql_num_rows($result);

//This area will hold the logic and stuff determining price of sale and whitch properties will be paid for this will post to the paypal secured area. remember https:	

?>


<p>You have <?=$numberProps ?> properties in our system.</p>

    <p>When selecting the lenght of time you wish to pay for a property you can select multiple lengths and those lenghts will add together. So say you want to pay for a property for 4 months you can do this by selecting the 3 	month check box and the 1 month check box.</p>
    <p>To delete a property out of the system go into manage your listings and select delete proerty for the property you wish to delete.
    <form method="post" action="<?=$_SERVER['PHP_SELF'] ?>">
    <input name="post" type="hidden" value="1" />
<table>
    <tr>
    <td><p>Title - Number</p></td><td>When Listed</td><td>Paid Till</td><td>Pay for</tr>
<?php //this while statment echos out the property name num date listed date paid for. 
$pay=1;

while( $row = mysql_fetch_assoc($result)){


?>
    <tr><td>
    
<p><?=$row['title'] ?> - <?=$row['propID'] ?> </p></td>
    <td><p><?=$row['whenlisted'] ?></td>
<td><p><?=$row['paidTill'] ?> </p></td>
    <td>1 Month<input name="onemonth[]" type="checkbox" value="<?=$row['propID'] ?>" />
    3 Month<input name="threemonth[]" type="checkbox" value="<?=$row['propID'] ?>" />
    6 month<input name="sixmonth[]" type="checkbox" value="<?=$row['propID'] ?>" />
    year<input name="year[]" type="checkbox" value="<?=$row['propID'] ?>" />

    </td>

<?php
$pay++;
$storedprops=$storedprops+" & "+$row['propID'];


}
echo "</tr>";
echo "</table>";
echo "<input name='submit' type='submit' value='Submit' />";
echo "</form>";
    
    
} elseif($_POST['post']==1) {
//this is the cycle back.
//recive the post
$onemonth=$_POST['onemonth'];
$threemonth=$_POST['threemonth'];
$sixmonth=$_POST['sixmonth'];
$year=$_POST['year'];

//recieve the arrays from the check boxes
$total1month=count($onemonth);
$total3month=count($threemonth);
$total6month=count($sixmonth);
$totalyear=count($year);


$total_props_purch=$total1month+$total3month+$total6month+$totalyear;

//find out price structure depending on total props paid for
if($total_props_purch==1) {
$onemonthprice=14.95;
$threemonthprice=41.95;
$sixmonthprice=77.95;
$yearprice=9.95;
$qualify="You qualify for no discounts";

} elseif($total_props_purch==2) {
$onemonthprice= 11.48;
$threemonthprice= 31.48;
$sixmonthprice= 58.48;
$yearprice= 74.98;	
$qualify="You qualified for the 2 property discount";

} elseif($total_props_purch<=4) {
$onemonthprice= 9.49;
$threemonthprice= 26.24;
$sixmonthprice= 38.99;
$yearprice= 50;			
$qualify="You qualified for the 4 or more property discount."; 
}

//now that you have the prices add them up
$a1=$total1month*$onemonthprice;
$a2=$total3month*$threemonthprice;
$a3=$total6month*$sixmonthprice;
$a4=$totalyear*$yearprice;
$totalprice=$a1+$a2+$a3+$a4;

//figure out the property ID's that are being paid for for each section
$id=0;
$a1mi=0;
$a3mi=0;
$a6mi=0;
$ymi=0;

foreach($onemonth as $value){
$property_id[$id]=$value;
$onemonthselected=$value;
$a1mi++;
$id++;
}

foreach($threemonth as $value){
$property_id[$id]=$value;
$threemonthselected=$value;
$a3mi++;
$id++;
}

foreach($sixmonth as $value){
$property_id[$id]=$value;
$sixmonthselected=$value;
$a6mi++;
$id++;
}

foreach($year as $value){
$property_id[$id]=$value;
$yearselected=$value;
$ymi++;
$id++;
}

echo "Your total for the following properties is $".$totalprice;
echo $qualify;

echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>";
echo "<input name='post' type='hidden' value='2' />";


echo "<h1>1 Month Payment</h1>";
foreach($onemonthselected as $value){
echo $value."<br />";
}

echo "$ ".$onemonthprice." each";


echo "<h1>3 Month Payment</h1>";
foreach($threemonthselected as $value){
echo $value."<br />";
}

echo "$ ".$threemonthprice." each";	

echo "<h1>6 Month Payment</h1>";
foreach($sixmonthselected as $value){
echo $value."<br />";
}

echo "$ ".$sixmonthprice." each";


echo "<h1>Full Year Payment</h1>";
foreach($yearselected as $value){
echo $value."<br />";
}

echo "$ ".$yearmonthprice." each";

$i=0;
while($i <= $total_props_purch){
?>
<input type="hidden" name="$property_id[]" value="<?=$property_id[$i] ?>" />

    <?
} 

echo "To remove these properties or change the length of time <a href='".$_SERVER['PHP_SELF']."'>please follow this link</a> or click the back button <br />";
?>
    	<input type="hidden" name="ammount" value="<?=$totalprice ?>" />

<?
echo "<input name='Next Step' type='submit' />";



} elseif($_POST['post']==2){

echo "post 2 congradulations I can move on to the input part";	


}

?>

 

EDIT: Please use the [code][/code] tags...

 

[attachment deleted by admin]

Link to comment
Share on other sites

Ok I have talked to my host and It appears that something wrote over 10 gigs of memory over in a matter of just a few minutes and it cause my server to crash. I have been experimenting and talking to them and it seem like this script has a memory leak some where in this script. No one has posted anything here yet. I understand that this is a complex matter but is their anyone out there who can help me. I am not sure how to stop this or how to change it. I would greatly appreciate some feed back. Thanks

Link to comment
Share on other sites

Thanks for the look over. I added the $i++ to the proper place and uploaded it and I am still getting the same problem. I was really hoping that was it something simple that I had just magorly overlook. Do you see any more errors. I really don't right now. Still kind of confused though on why I didn't get an error or something. Just a blank screen and that is it. Well still getting a blank screen.

Link to comment
Share on other sites

Just to clarify, you did put the $i++ inside the php block and not html, right?

 

while($i <= $total_props_purch){
$i++;
?>
<input type="hidden" name="$property_id[]" value="<?=$property_id[$i] ?>" />

    <?
} 

 

Not:

while($i <= $total_props_purch){
?>
<input type="hidden" name="$property_id[]" value="<?=$property_id[$i] ?>" />
$i++;
    <?
} 

This second one wouldn't change anything.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.