forms don't sen data
Posted by: kormorin (---.pool.t-online.hu)
Date: March 24, 2008 06:46PM

Hello,

I have a most strange problem with my wamp server: html forms don't send their variables to php! I checked it out with a webserver, and it's not my syntax. However the very same script is able to connect mysql databases, do mathematical stuff, etc. So it might be sg with Apache... (?)

This thing is driving me crazy even more cuz I don't have any error messages to search for or something. Please give me a clue or if it was mentioned earlier on this forum, link it to me!

thanks a lotÍ!

Options: ReplyQuote
Re: forms don't sen data
Posted by: msteudel (---.hsd1.or.comcast.net)
Date: March 24, 2008 08:17PM

Can you post your the code you are using?

If you switch your form to use get do you see the variables in the URL?

What happens if you post your form to a test.php file that contains the following:

<?php

echo "<pre>";
print_r( $_REQUEST );
echo "</pre>";

MS

Options: ReplyQuote
Re: forms don't sen data
Posted by: kormorin (---.pool.t-online.hu)
Date: March 24, 2008 09:45PM

Hey,

thanks a lot, both ideas seemed to be very helpful, it's only I don't have the knowledge to get to the conclusionsmiling smiley). Yes, if I change method to get, it DOES show the values in the URL. Similarly, the script you sent printed all the values too!!!

Here is my syntax:
<?php
include ("connect.php"winking smiley;
echo "<form method=get>
<input type=text name=pad ></input>pad<br>
<input type=text name=szek />szék<br>
<input type=text name=szekcio />szekció<br>
<input type=text name=osztaly />osztály<br>
<input type=text name=emelet />emelet<br>
<input type=text name=oldal />oldal<br>
<input type=submit value='Szék hozzáadása'>
</form>
";

$id = "$pad"."$szek";
$query = "INSERT INTO `synagogue`.`szek` (
`id` ,
`pad` ,
`szek` ,
`szekcio` ,
`oldal` ,
`emelet`
)
VALUES (
'$id', '$pad', '$szek', '$szekcio', '$oldal', '$emelet'
);
";


mysql_query ($query, $connect) or die ("$query nem teljesült ". mysql_error() );

?>

Honestly, this is so exciting, I'm almost happy to have this problemsmiling smiley. Thanks again for every help, one can learn a lot from these problems, I hope this one won't stuck me for too long.

Options: ReplyQuote
Re: forms don't sen data
Posted by: msteudel (---.hsd1.or.comcast.net)
Date: March 24, 2008 10:47PM

Cool ... well that means that your form is sending the values you just aren't processing the correctly yet.

So from your code, I'm assuming you want to submit the form then insert the values from the user into a db?

Create two files, one is your form the other is the php page that will insert the values:

form.html

<form method="post" action="insert.php">
// all your form code
</form>


insert.php

<?php

$id = mysql_real_eascape_string( $_POST['pad'] . $_POST['szek'] );
$pad = mysql_real_escape_string( $_POST['pad'] );

// etc. etc.

$query = "INSERT INTO `synagogue`.`szek` (
`id` ,
`pad` ,
`szek` ,
`szekcio` ,
`oldal` ,
`emelet`
)
VALUES (
'$id', '$pad', '$szek', '$szekcio', '$oldal', '$emelet'
);
";


mysql_query ($query, $connect) or die ("$query nem teljesült ". mysql_error() );

Let me know if something's not clear...

Mark

Options: ReplyQuote
Re: forms don't sen data
Posted by: kormorin (---.pool.t-online.hu)
Date: March 25, 2008 01:27AM

I am afraid this is something more tricky...
The function "mysql_real_escape_string" seems to be handy, but it didnt work for me. I got the following error message:
Fatal error: Call to undefined function mysql_real_eascape_string() in C:\wamp\www\synagogue\insert.php on line 3

However, the problem seems to be nastier than that! Earlier I tried some echos and it turned out, that I cannot use data from forms at all! To simplify the problem I created a simple form like this:

<form action='testb.php'><input type=text name=test /><input type=submit></form>

and a "testb.php" file with the following lines:

echo "$test";
echo "<br>i'm running";

The result is negative: php is running, but it cant see the variable given from the form. Other simple games like this showed that it is able to deal with variables described in the php code itself. I tried to get some clues from my php errorlog, but the things I saw there didn't seem to be referring to this problem.

I hope you have some clue,

thanks
Adam

Options: ReplyQuote
Re: forms don't sen data
Posted by: yfastud (Moderator)
Date: March 25, 2008 01:31AM

How did you run your php file? Did you save your_file.php in c:/wamp/www and run as follows:

http: //localhost/your_file.php

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: forms don't sen data
Posted by: msteudel (---.hsd1.or.comcast.net)
Date: March 25, 2008 04:50PM

In order to access data that is sent via post or get you need to use either:

$_GET, $_POST, or $_REQUEST

Here's a tutrial on it:
[www.tizag.com]

Options: ReplyQuote
Re: forms don't sen data
Posted by: kormorin (---.pool.t-online.hu)
Date: March 25, 2008 07:11PM

Oh yes, I see now it was a simple php issue. Sorry for stealing your times folks, but I guess it happens a number of times on this forum...

I think in the version I was used to I didnt HAVE TO use that stuff. Anyhow thanks for your patience, all is functioning now for the moment.

Software is cool
best of luck
Adam

Options: ReplyQuote
Re: forms don't sen data
Posted by: msteudel (---.hsd1.or.comcast.net)
Date: March 25, 2008 07:17PM

Yeah in older versions some folks had a option on called:

register_globals

Which is bad ...

[www.colder.ch]

Options: ReplyQuote


Sorry, only registered users may post in this forum.