0

Hi all,

I've written some code which seems to be working when isolated on testing pages, however, as soon as I integrate the codes within my site files, the code no longer works.

What the code does: currently, when the first page loads, you have an option of which template you would like to purchase. Once you press the submit button, a new page loads and inserts the "hidden" values of the chosen template into a new text input.

Like I said, the code works on its own, but as soon as I implement it within the rest of my site files, the values will no longer show on the second page.

Obviously something within my site files is interfering with this code, right? I've tried deleting each javascript or php code alone and test it out one at a time to see what's breaking it, but no luck (P.S. I've even tried this 3 times, thinking I may have forgotten to delete one at some point)! Now there's way too much PHP code required to load each page, so I wouldn't be able to copy/paste or upload the files here.

The question: How would I go about finding the code that seems to obviously be interfering with the new working code? Is there something like Firebug that exists for PHP code??:?:


Please see the below two files (working code on its own):

File 1: index.php

<?php
//*
$T1_R_ID = "#1 - Regular"; 
$T1_R = 25; 
$T1_E_ID = "#1 - Exclusive"; 
$T1_E = 100; 
//*
$T2_R_ID = "#2 - Regular"; 
$T2_R = 50; 
$T2_E_ID = "#2 - Exclusive"; 
$T2_E = 200; 
//*
$T3_R_ID = "#3 - Regular"; 
$T3_R = 75; 
$T3_E_ID = "#3 - Exclusive"; 
$T3_E = 300; 
//*
$T4_R_ID = "#4 - Regular"; 
$T4_R = 100; 
$T4_E_ID = "#4 - Exclusive"; 
$T4_E = 400; 
?>
<html>
<head>

</head>
<body>
<form action="process.php" method="post">
<label><?php echo $T1_R_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T1_R ?>" />
<input type="hidden" name="temp_id" value="<?php echo $T1_R_ID ?>" />
<input type="submit" name="submit" value="Buy Regular">
</form>
<form action="process.php" method="post">
<label><?php echo $T1_E_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T1_E ?>" />
<input type="hidden" name="temp_id" value="<?php echo $T1_E_ID ?>" />
<input type="submit"name="submit" value="Buy Exclusive">
</form>
<form action="process.php" method="post">
<label><?php echo $T2_R_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T2_R ?>">
<input type="hidden" name="temp_id" value="<?php echo $T2_R_ID ?>" />
<input type="submit" name="submit" value="Buy Regular">
</form>
<form action="process.php" method="post">
<label><?php echo $T2_E_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T2_E ?>">
<input type="hidden" name="temp_id" value="<?php echo $T2_E_ID ?>" />
<input type="submit"name="submit" value="Buy Exclusive">
</form>
<form action="process.php" method="post">
<label><?php echo $T3_R_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T3_R ?>" />
<input type="hidden" name="temp_id" value="<?php echo $T3_R_ID ?>" />
<input type="submit" name="submit" value="Buy Regular">
</form>
<form action="process.php" method="post">
<label><?php echo $T3_E_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T3_E ?>" />
<input type="hidden" name="temp_id" value="<?php echo $T3_E_ID ?>" />
<input type="submit"name="submit" value="Buy Exclusive">
</form>
<form action="process.php" method="post">
<label><?php echo $T4_R_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T4_R ?>">
<input type="hidden" name="temp_id" value="<?php echo $T4_R_ID ?>" />
<input type="submit" name="submit" value="Buy Regular">
</form>
<form action="process.php" method="post">
<label><?php echo $T4_E_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T4_E ?>">
<input type="hidden" name="temp_id" value="<?php echo $T4_E_ID ?>" />
<input type="submit"name="submit" value="Buy Exclusive">
</form>
</body>
</html>

File 2: process.php

<?php
 
	$temp_id = $_POST["temp_id"];
	$temp_price = $_POST["temp_price"];
?>

<input type="text" readonly id="chosen" name="chosen" value="<?php echo $temp_id ?>" alt="<?php echo $temp_price ?>" />

Any help or advice whatsoever would be greatly appreciated.

L.

3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by ddymacek
0

Hi all,

I've written some code which seems to be working when isolated on testing pages, however, as soon as I integrate the codes within my site files, the code no longer works.

What the code does: currently, when the first page loads, you have an option of which template you would like to purchase. Once you press the submit button, a new page loads and inserts the "hidden" values of the chosen template into a new text input.

Like I said, the code works on its own, but as soon as I implement it within the rest of my site files, the values will no longer show on the second page.

Obviously something within my site files is interfering with this code, right? I've tried deleting each javascript or php code alone and test it out one at a time to see what's breaking it, but no luck (P.S. I've even tried this 3 times, thinking I may have forgotten to delete one at some point)! Now there's way too much PHP code required to load each page, so I wouldn't be able to copy/paste or upload the files here.

The question: How would I go about finding the code that seems to obviously be interfering with the new working code? Is there something like Firebug that exists for PHP code??:?:


Please see the below two files (working code on its own):

File 1: index.php

<?php
//*
$T1_R_ID = "#1 - Regular"; 
$T1_R = 25; 
$T1_E_ID = "#1 - Exclusive"; 
$T1_E = 100; 
//*
$T2_R_ID = "#2 - Regular"; 
$T2_R = 50; 
$T2_E_ID = "#2 - Exclusive"; 
$T2_E = 200; 
//*
$T3_R_ID = "#3 - Regular"; 
$T3_R = 75; 
$T3_E_ID = "#3 - Exclusive"; 
$T3_E = 300; 
//*
$T4_R_ID = "#4 - Regular"; 
$T4_R = 100; 
$T4_E_ID = "#4 - Exclusive"; 
$T4_E = 400; 
?>
<html>
<head>

</head>
<body>
<form action="process.php" method="post">
<label><?php echo $T1_R_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T1_R ?>" />
<input type="hidden" name="temp_id" value="<?php echo $T1_R_ID ?>" />
<input type="submit" name="submit" value="Buy Regular">
</form>
<form action="process.php" method="post">
<label><?php echo $T1_E_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T1_E ?>" />
<input type="hidden" name="temp_id" value="<?php echo $T1_E_ID ?>" />
<input type="submit"name="submit" value="Buy Exclusive">
</form>
<form action="process.php" method="post">
<label><?php echo $T2_R_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T2_R ?>">
<input type="hidden" name="temp_id" value="<?php echo $T2_R_ID ?>" />
<input type="submit" name="submit" value="Buy Regular">
</form>
<form action="process.php" method="post">
<label><?php echo $T2_E_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T2_E ?>">
<input type="hidden" name="temp_id" value="<?php echo $T2_E_ID ?>" />
<input type="submit"name="submit" value="Buy Exclusive">
</form>
<form action="process.php" method="post">
<label><?php echo $T3_R_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T3_R ?>" />
<input type="hidden" name="temp_id" value="<?php echo $T3_R_ID ?>" />
<input type="submit" name="submit" value="Buy Regular">
</form>
<form action="process.php" method="post">
<label><?php echo $T3_E_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T3_E ?>" />
<input type="hidden" name="temp_id" value="<?php echo $T3_E_ID ?>" />
<input type="submit"name="submit" value="Buy Exclusive">
</form>
<form action="process.php" method="post">
<label><?php echo $T4_R_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T4_R ?>">
<input type="hidden" name="temp_id" value="<?php echo $T4_R_ID ?>" />
<input type="submit" name="submit" value="Buy Regular">
</form>
<form action="process.php" method="post">
<label><?php echo $T4_E_ID ?></label>
<input type="hidden" name="temp_price" value="<?php echo $T4_E ?>">
<input type="hidden" name="temp_id" value="<?php echo $T4_E_ID ?>" />
<input type="submit"name="submit" value="Buy Exclusive">
</form>
</body>
</html>

File 2: process.php

<?php
 
	$temp_id = $_POST["temp_id"];
	$temp_price = $_POST["temp_price"];
?>

<input type="text" readonly id="chosen" name="chosen" value="<?php echo $temp_id ?>" alt="<?php echo $temp_price ?>" />

Any help or advice whatsoever would be greatly appreciated.

L.

There is no alt attribute on input element.

If you want to check the value you send in post method, just check it first by print the array $_POST, on file process.php, the code look like this:

print_r($_POST); // this will print all $_POST value you sent
echo $_POST['temp_id']."<br />";
echo $_POST['temp_price'];

If you want implement into your code, look like this:

<?
$temp_id = $_POST["temp_id"];
$temp_price = $_POST["temp_price"];
?>
<input type="text" readonly id="temp_id" name="temp_id" value="<?php echo $temp_id; ?>" /> <input type="text" readonly id="temp_price" name="temp_price" value="<?php echo $temp_price;?>" />

or if you want to put the value in one input form look like this:

<input type="text" readonly id="temp_id" name="temp_id" value="<?php echo $temp_id; ?> - <?php echo $temp_price;?>" />
0

There is no alt attribute on input element.

If you want to check the value you send in post method, just check it first by print the array $_POST, on file process.php, the code look like this:

print_r($_POST); // this will print all $_POST value you sent
echo $_POST['temp_id']."<br />";
echo $_POST['temp_price'];

If you want implement into your code, look like this:

<?
$temp_id = $_POST["temp_id"];
$temp_price = $_POST["temp_price"];
?>
<input type="text" readonly id="temp_id" name="temp_id" value="<?php echo $temp_id; ?>" /> <input type="text" readonly id="temp_price" name="temp_price" value="<?php echo $temp_price;?>" />

or if you want to put the value in one input form look like this:

<input type="text" readonly id="temp_id" name="temp_id" value="<?php echo $temp_id; ?> - <?php echo $temp_price;?>" />

Thank you for your response.

I forgot to mention, the alt attribute will be used to calculate the total costs with other JS codes. Too many files if you ask me to be displayed on here.

The value to the input alt will eventually be shown into a div tag.

I just want to know how to grab the values submitted from the first page onto the second (depending on which button the visitor has clicked).

What would be a possible cause for such code (...when I say such code, I refer to the code I've written here on the first post) to no longer work when implemented into the rest of the site files?

0

I have some other php code on the process.php like so:

<?php 
            if(isset($_POST['Submit'])) {

I've tried deleting this code to see if it were interfering with the rest of my PHP code, but it doesn't seem to be.

I don't have anywhere else some code showing $temp_id = x or $temp_price = y so what could possibly be causing this to no longer display?

L.

0
// do more debugging of your code.  
// actually that isset 'Submit' is failing.
// this fails everytime.
    if (isset($_POST['Submit'])) {

		echo "SUBMIT IS SET!!!<BR />";
	}
     // your form submit buttons are all names submit, lowercase.
	if (isset($_POST['submit'])) {
                // this evaluates true everytime.
		echo "little submit IS SET!!!<BR />";
	}
	$temp_id = $_POST["temp_id"];
	$temp_price = $_POST["temp_price"];
	
    print_r($_POST); // this will print all $_POST value you sent
    echo $_POST['temp_id']."<br />";
    echo $_POST['temp_price'];

<input type="text" readonly id="chosen" name="chosen" value="<?php echo $temp_id ?>" alt="<?php echo $temp_price ?>" />
0

Thanks for your response.

There are two files posting information.

The first file is the index.php file which lets the customer choose their template.

The second file will be the order confirmation file, which should show the chosen template info and have other additional options below.

This second file, submits new information when the customer hits the submit button from the second file (order confirmation file).

This is the code for the submit button on the second file: <input id="submit" type="submit" class="button small float-right" name="Submit" value="Checkout Now"> All the submit buttons on the first file are showing as name="submit" and the second file, the submit is name="Submit".

L.

0

There can only be one file posting information at a time. You may have one 'form processor page' that will take info from either post, but why?...
where is your second file code?
index.php should post to x.php, process index info.
off that info, x.php should populate from data and submit to y.php.
y.php processes x.php info, all submitted and processed from index.php.
this is my understanding of what you are trying to do...
you responded but i have no idea what you are asking for at this point please clarify. what is your error?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.