Closed Thread Icon

Topic awaiting preservation: Problem with Post and form (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=30917" title="Pages that link to Topic awaiting preservation: Problem with Post and form (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Problem with Post and form <span class="small">(Page 1 of 1)</span>\

 
OlssonE
Maniac (V) Inmate

From: Eagleshieldsbay, Sweden
Insane since: Nov 2001

posted posted 03-16-2009 14:27

Hi!
I have a problem. When i send the form to itself it doesn't get the post values.
i have tried having the sql and php code about the form in a separate page. But that didn't work either.

code:
<body>
<div id="center">
<div id="logo"><img style="border: 0px solid ; width: 150px; height: 100px;" alt="" src="../bilder/logga.jpg"></div>

<div id="banner"><img style="border: 0px solid ; width: 650px; height: 100px;" alt="" src="../bilder/slogga.jpg"></div>

<div id="menu">

<?
include 'menu.php';
?>
</div>
<div id="main">
<div class="content">
<?


//$datum = date("j/n - y H:i");
//$datum = gmdate("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 1998));
//$timezone  = +1; //(GMT -5:00) EST (U.S. & Canada)
//$datum = gmdate("j/n - y H:i:s", time() + 3600*($timezone)); 


$submit =  $_POST['submit'];
$bild =  $_POST['bild'];
$info =  $_POST['info'];
$datum =  $_POST['datum'];
$remove = $_GET['remove'];
$db = mysql_connect("lager.noh.se", "login","password");
mysql_select_db("lagernoh",$db);


if (isset($submit)) {
	
	$sql = "INSERT INTO lager (info,bild,datum) VALUES ('$info','$bild','$datum')";
	$back = mysql_query($sql);
}

if (isset($remove)) {
	
	 $back = mysql_query("DELETE FROM lager WHERE id=$remove",$db);
} 

$result = mysql_query("SELECT * FROM lager ORDER BY ID DESC",$db);




if ($myrow = mysql_fetch_array($result)) {
	
	do{


		echo "<p align=\"center\"> <img src=\"../bilder/lager".$myrow["bild"]."\"/ ><br /><br />".$myrow["info"]."</p><br /> <p align=\"right\">"				.$myrow["datum"]." <a href=\"index.php?remove=".$myrow["id"]."\">ta bort</a></p>";

 		} while ($myrow = mysql_fetch_array($result));

} else {
	echo "inget i lager just nu!";
}


?>


<form action="index.php" method="post" enctype="text/plain">
Bildnamn: <br />
<input type="text" name="bild" /> <br />
Information: <br />
<input type="text" size="80" maxlength="200" name="info" /> <br />
Datum: <br />
<input type="text" name="datum" /> <br />
<input type="submit" name="submit" value="Lägg i lager" />
<input type="reset" value="Rensa" />
</form>

</div>
</div>

</div>
</body>



Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 03-16-2009 16:07

define 'does not get the post values'.

What happens if you stick a
<?php
var_dump($_POST);
?>
right at the top of your script??

OlssonE
Maniac (V) Inmate

From: Eagleshieldsbay, Sweden
Insane since: Nov 2001

posted posted 03-16-2009 17:37
quote:

Tyberius Prime said:

define 'does not get the post values'.



Simply it doesn't send the Post values bild, info, datum through to the script...


I tested the var_dump($_POST)
and it doesn't show any values...!!?

any more idea's?

OlssonE
Maniac (V) Inmate

From: Eagleshieldsbay, Sweden
Insane since: Nov 2001

posted posted 03-16-2009 18:10

I made a quick fix...
It seems that is not an problem in the PHP code but with the form html???
I used get instead of post and it worked. Maybe an "standards" problem
or a dreamhost limitation....
good day,,!

Nathus
Bipolar (III) Inmate

From: Minnesota
Insane since: Aug 2003

posted posted 03-16-2009 21:48

The problem is the enctype="text/plain"

http://www.talkphp.com/absolute-beginners/2048-enctype-text-plain-can-someone-explain-why.html

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 03-17-2009 11:46

the point was to discern where your data flow breaks down
'Simply it doesn't send the Post values bild, info, datum through to the script...' can mean anything from 'script does not retrieve form data', to 'isn't stored in the database'.

As you've found, the problem was the first part, as illustrated by $_POST being empty.
And a cookie for Nathus for pointing out where the real deal is

OlssonE
Maniac (V) Inmate

From: Eagleshieldsbay, Sweden
Insane since: Nov 2001

posted posted 03-17-2009 15:39

Thank you Nathus and TP!

*Cookie*


« BackwardsOnwards »

Show Forum Drop Down Menu