Click to See Complete Forum and Search --> : POST handling error
hojoff79
September 9th, 2009, 01:54 AM
So basically I have a page where I am receiving a post variable to use to bring up database information but then lower on the page, I have another form using the post method to go to another handling page. The problem is, that when the first page receives the post variable from the page before it, then it cannot pass on the post variable in the form at the bottom of the page.
I know the recieving the post variable on the same page as putting out a new one is the problem because whenever I load the page without giving it the post variable, even though some parts of the page screw up, the form at the bottom can pass on the POST variable.
Is there any reason you cannot recieve a POST variable and send a new one on the same php page???
Here is a diagram of the flow:
-previouspage.php (passes POST variable on to mainpage.php)
-mainpage.php (page where the problem occurs, takes the POST variable from previouspage.php and uses it to pull up database information, then has another form at the bottom which sends a new POST variable to lastpage.php)
-lastpage.php (DOES NOT take the POST variable from mainpage.php unless mainpage.php did not take the POST variable from previouspage.php)
Thank you for your help in advance.
socialite
September 9th, 2009, 07:05 AM
mabey you should post the code but it shouldn't be a problem perhaps youre atomated code when you press submit changes the post value or runs some code you dont want it to.
hojoff79
September 9th, 2009, 12:47 PM
I don't think so because I've tried copying and pasting the form into a second file and it works perfectly, but I'll post the code anyway to make it more clear what the page does.
<?php
session_start();
if (!$_SESSION['valid_user'])
{
$_SESSION['attempt']=1;
Header("Location:index.php");
}
require_once 'database.php';
$dbname = "TextbookInfo";
@mysql_select_db($dbname) or die('Database does not exist');
$user = $_SESSION['valid_user'];
$classnum = $_POST['class'];
$query= "SELECT class, bookname, isbn, requirement, notes FROM textbookinfo WHERE classnum='$classnum'";
$result = mysql_query($query);
mysql_close();
$rows = @mysql_num_rows($result);
$class = mysql_result($result, 0, "class");
echo "Books Assigned for $class<br><br>";
echo '<html>';
echo '<form name="form" method="POST" action="editclasspage.php">';
echo '<input name="hello">';
echo '<input type="submit" name="edit" value="Edit Entry">';
echo '</form>';
echo '</html>';
echo "<br><b>Links</b><br>";
echo '<a href="members.php">Back To Member\'s Homepage</a>';
?>
And it's the hello variable i can't get in the editclasspage.php handler (which i know works because with other simpler code it works perfectly). also have tried the isset($_POST['edit']) and that doesn't register the variable either.
Hope this helps
hojoff79
September 11th, 2009, 02:14 AM
does anyone know any better forums, cause frankly the last 3 posts I have put up here have been unanswered with any results.....I mean i'm not a confusing programmer and they can't solve these simple problems. I need a forum with more experienced programmers running things. What is the most visited and with the best advice?
bubu
September 13th, 2009, 09:52 PM
You could try saving $_POST to $_SESSION so the last page gets it this way.
Another method is, if the middle page will present another form, you can put hidden fields filled with the data from previous page POST.
Are you doing a wizard style form?
You can try asking questions at ##php channel at Freenode IRC server.
hojoff79
September 14th, 2009, 12:10 AM
I guess I could use the session variable but I'm not even sure that would work here because the problem is the form from the second page doesn't pass it's variable to the thrid page so I can't handle the variable created on the second page. And it is making me crazy and it seems like a pretty simple thing so I would really like to figure this out. I have broken it down on my server to the most basic version of what I am trying to do and still have the same problem.
IMPORTANT: Just to clarify, I am NOT trying to get a variable from the first page, through the second page and to the third page. The first page is giving the second page a variable which it will echo, then in a COMPLETELY UNRELATED field at the bottom, it is getting another variable to pass on to the third page (and the fact it is completely unrelated to the variable from the first page makes me wonder why the first page variable matters).
HERE ARE THE CODES!!!!!!
test.php, passes along variable hello to test2.php
<?php
echo "<html>";
echo "<form name='hello' method='POST' action='test2.php'>";
echo "Hello Variable <input name='hello'>";
echo "<input type='submit' name='name'>";
echo "</form>";
echo "</html>";
?>
test2.php, this should accept the variable from test.php and then have a completely new form to pass on to classeditpage.php
<?php
$status = $_POST['hello'];
echo "$status";
echo '<form name="form" method="POST" action="editclasspage.php">';
echo '<input type= "text" name="hello">';
echo '<input type="submit" value="Edit Entry">';
echo '</form>';
echo '</html>';
?>
classeditpage.php this should just take the text variable from test2.php and display it, it only it does not work when test2.php takes the variable from test.php. If i loadup test2.php without it getting the variable from test.php, then it CAN pass the variable on to this last page classeditpage.php
<?php
$status = $_POST['hello'];
echo "$status";
?>
<html>
<br>
<br>
<a href="members.php">Back to Members Page</a>
</html>
bubu
September 16th, 2009, 09:27 PM
It's very strange because I copy & pasted your code and it worked here. The code does nothing facy, it should work on a normal PHP setup.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.