Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

forms problems

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

forms problems

Postby tranquillo » Mon Jan 20, 2003 7:58 am

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
-------
tranquillo
New php-forum User
New php-forum User
 
Posts: 74
Joined: Sun Nov 24, 2002 6:48 pm
Location: katrineholm

Postby xlordt » Mon Jan 20, 2003 8:16 am

try it this way...

Code: Select all
<?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
User avatar
xlordt
New php-forum User
New php-forum User
 
Posts: 34
Joined: Thu Dec 12, 2002 9:00 pm
Location: NJ

Postby tranquillo » Mon Jan 20, 2003 8:23 am

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
tranquillo
New php-forum User
New php-forum User
 
Posts: 74
Joined: Sun Nov 24, 2002 6:48 pm
Location: katrineholm

Re: forms problems

Postby WiZARD » Mon Jan 20, 2003 8:41 am

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
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby tranquillo » Mon Jan 20, 2003 9:02 am

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"
tranquillo
New php-forum User
New php-forum User
 
Posts: 74
Joined: Sun Nov 24, 2002 6:48 pm
Location: katrineholm

Postby xlordt » Tue Jan 21, 2003 7:44 am

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

$ett = $_POST['ett'];

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

this is what's printed:
", hej"


Code: Select all
<?php

$ett = $_POST['ett'];

echo $ett . " hej ";
?>
User avatar
xlordt
New php-forum User
New php-forum User
 
Posts: 34
Joined: Thu Dec 12, 2002 9:00 pm
Location: NJ

Postby Redcircle » Wed Jan 22, 2003 12:25 am

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.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.