Jump to content

POST on wrong URL level


xcandiottix

Recommended Posts

The way I understand posting a form to work is that when you hit submit the information is attached to the end of the url of the new page where your script can then get it and use it.

 

I have a form that is an include on a page, like so:

 

thepage.php

include: theform.php

 

When i fill out the form and hit submit.. the next page acts as if it has not received any of the posted information.

 

example: echo $_POST['input1'] results in nothing

 

If i go directly to theform.php and fill out and submit the form it works fine.

 

example: echo $_POST['input1'] results in whatever was typed in the first box.

 

So how can I get it to work while being included?

Link to comment
Share on other sites

Here's what we've got:

 

the form (it posts back to itself therefore no action):

<?php
//administration panel, change information within the quotes.
$appname = "Shout";
$appcreator = "Kcandiotti400";
$versionnumber = "1.0";
?>
<?php require_once('../includes/tools/applicationframeA.php');
//$xml = simplexml_load_file("../includes/tools/testingUMDOT.xml");
?>
<!-- 3. PHP script for operation of shout box -->
<?php
//A. Save new post to shouts.txt
echo $_SERVER['PHP_SELF'];
echo "<BR>";
$myFile = "../includes/2/shouts.txt";
$input = $_POST['2input'];
if($input == ""){
//echo $xml->home;
}
else{
echo $input;
//B. Append shouts.txt with new post
$username = $xml->visitor;
$username = '<a href="http://www.appdilly.com/users/'.$username.'">'.$username.'</a>';
//C. Append shouts.txt or if the file is larger then 1000 bytes erase all and start over with this post.
$fh = fopen($myFile, 'a');
if(filesize($myFile) > 1000){fclose($fh); $fh = fopen($myFile, 'w');}
//C. End
$stringData = $username." - ".$input."<br> \n";
fwrite($fh, $stringData);
//B. End	
}
//A. End
//D. Open .txt and get all previous shouts
$fh = fopen($myFile, 'r');
$shouts = fread($fh,filesize($myFile));
fclose($fh);
//D. End
?>
<!-- 1. Recent shouts holder -->
<?php echo $shouts?>
<!-- 1. End -->
<form method="post"> <!-- 2. This is the input box for the app -->
<input name="2input" type="text" size="30" maxlength="144" /><br />
<input name="2submit" type="submit" value="Shout!" />
<input name="2refresh" type="submit" value="Refresh" />
</form> <!-- 2. End -->
<?php require_once('../includes/tools/applicationframeB.php'); ?>

 

So the above, as its own page works just fine. It is included in a really big page, by which an ajax script calls it up. It's a lot of code to post on here but it's live so maybe you can see it in action to help:

 

Just the form working by itself:

http://appdilly.com/applications/appfiles/2.php

 

Included on a page:

http://www.appdilly.com/member/user_page.php?u=Kcandiotti400

 

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.