|
Posted by Danny Wong on 06/18/05 18:03
Hi,
Try adding this code before the $query statement
if you are using 'POST' in the <form ... method="POST">
$name = $HTTP_POST_VARS["name"] ;
$location = $HTTP_POST_VARS["location"] ;
if you are using 'GET' in the <form ... method="GET">
$name = $HTTP_GET_VARS["name"] ;
$location = $HTTP_GET_VARS["location"] ;
For security reasons, your Server Admin may turn off
the --enable-register-global flag in php.ini. I face this problem too and I
use the above method to work around.
Danny Wong
"Ant" <SPAMBGONE@nospam.com> ΌΆΌg©σΆl₯σ·s»D:d91c91$m3$1@wisteria.csv.warwick.ac.uk...
> Hi,
>
> I've just started learning php and I'm having a problem.
> I'm following a tutorial for creating a guestbook with a mysql backend -
> everything is set up correctly.
>
> Here's the relevant code for the page where the user types in their name
> and location (sign.php)
>
> <h2>Sign my guestbook</h2>
> <form action="create_entry.php">
> <b>Name:</b>
> <input type="text" size=40 name=name>
> <br>
> <b>Location:</b>
> <input type="text" size=40 name=location>
>
> What I want is the values stored in name and location to be entered into
> the database.
>
> In create_entry.php I have this code:
> $query = "INSERT INTO guestbook VALUES ('$name', '$location')" ;
>
> Now for some reason the variables name and location are not entered in the
> database, instead blank fields are entered. When I replace the variable
> names with absolute values the database is updated correctly to show those
> values so I know the query works. But somehow the name and location are
> not being sent from sign.php to create_entry.php even though they are
> there and present in the header info
> e.g
>
> http://localhost/create_entry.php?name=John&location=London&submit=Sign
>
> Anyone know what I'm doing wrong, any help much appreciated.
>
> Thanks
> --
> Ant
>
Navigation:
[Reply to this message]
|