forms problems

A

Anonymous

Guest
hi..

I've created a guestbook and it works just great on my comp. but now when I put it on a free test server it won't work anymore...

I'm using a form with the post action thing to a new php page, and there I've done a $txt = $_POST["txt"]; connection. but something's not working, because nothing is entered into the database. is there a problem using that $txt = $_POST["txt"]; connection thing on some servers or something?
and I'm sure it's that or the form that's the problem. been trying to change everything else...

this is the code:

guestbook.htm
-------------------
<form name="guestbook" method="post" action="guestbook.php">
<p><br><table border="0" class="textsmallbold"><tr>
<td>Namn : </td>
<td><input type="text" name="namn"></td></tr>
<tr>
<td>E-post : </td>
<td><input type="text" name="epost"></td></tr>
<tr>
<td>Meddelande : </td>
<td>
<textarea name="txt"></textarea>
<input type="submit" name="Submit" value="Submit" class="button">
---------------------

guestbook.php
---------------------
<?php
$db = mysql_connect("localhost", "xxxxxx", "xxxxxx");
mysql_select_db("DB_nac88321",$db);
$namn = $_POST["namn"];
$epost = $_POST["epost"];
$txt = $_POST["txt"];

if ($txt) {

(insert query and all that)

?>


<?php
} else {
printf("<meta http-equiv='refresh' content='0;URL=forgot.htm'>\n");
}
?>

-------------
would be realy happy if someone could tell me what's wrong, and why... it just buggs me coz it worked fine until I put it on another server...

what happens when I try to enter a message to the guestbook is that it's just totaly ignored. it says I haven't put any text in the textbox... but I'm sure I have... and if I get rid of that "if ($txt)" thing nothing happens... one message is entered in the guestbook, but it's blanc. it's like nothing is sent to the guestbook.php page at all. or that the connection thing don't work...
please help..

-s
_________________
-------
stefan
-------
 
try it this way...

Code:
<?php
$db = mysql_connect("localhost", "xxxxxx", "xxxxxx");
mysql_select_db("DB_nac88321",$db);
$namn = $_POST["namn"];
$epost = $_POST["epost"];
$txt = $_POST["txt"];

if (($submit) && ($txt))  {

(insert query and all that)
echo"Your input is has been accepted =) ";
printf("<meta http-equiv='refresh' content='0;URL=forgot.htm'>\n");
}else{
?>

<form name="guestbook" method="post" action="guestbook.php">
<p><br><table border="0" class="textsmallbold"><tr>
<td>Namn : </td>
<td><input type="text" name="namn"></td></tr>
<tr>
<td>E-post : </td>
<td><input type="text" name="epost"></td></tr>
<tr>
<td>Meddelande : </td>
<td>
<textarea name="txt"></textarea>
<input type="submit" name="Submit" value="Submit" class="button"> 

<?php
}
?>

good luck
 
thanks... but it's not the "if" statement that is the problem... the form does not send the text to the php page... or it does and the $_POST connection is messed up...
if I take away the "if" part all together, it still won't work...

I wanna know if there's any other way other than using $_POST. or if I'm doing something wrong with the forms...

-s
 
As i understand you test under Windows, but forgot what all hosters work under Unix..... try change $namn = $_POST["namn"]; at $namn = $_POST['namn']; and see configurations for php
 
thanks... but it's still not working...

now I've got a reeeeaaaallllyyy simple form > php code...

------------
<form name="form1" method="post" action="test4.php">
<input type="submit" name="Submit" value="Submit">
<input type="text" name="ett">
</form>
---------------

test4.php
----------------
<?php

$ett = $_POST['ett'];

echo "$ett, hej";
?>
----------------

this is what's printed:
", hej"
 
test4.php
----------------
<?php

$ett = $_POST['ett'];

echo "$ett, hej";
?>
----------------

this is what's printed:
", hej"

Code:
<?php 

$ett = $_POST['ett']; 

echo $ett . " hej "; 
?>
 
what version of PHP is on the test server. $_POST is only supported on versions 4.1 and later. Try using $HTTP_POST_VARS['txt'] instead.
 
Back
Top