Re: Transferring variables from form to php
There is a small mistake in your code
The line echo ".$wName., .$wEmail.";
should be echo $wName.", ".$wEmail";
See if that helps...
Yours, Tim
DrTebi <DrTebi@yahoo.com> wrote in message news:<pan.2004.05.14.12.16.00.143000@yahoo.com>...
> On Sat, 10 Jan 2004 13:33:31 -0800, L.Ray wrote:
>
> > I'm trying to pass data from an HTML form to PHP. Later, I'll write the
> > data to a database. Please look at this simple html form, php code,
> > and the output and tell me what I'm doing wrong. Thanks in advance:
> >
> >
> > <!-- Sample.html -->
> > <html>
> > <body>
> >
> > <form action="simple.php" method="POST" >
> > Name: <input type="text" name="wName" size="20"><br>
> > Email: <input type="text" name="wEmail" size="20"><br>
> > <input type="submit" value="submit" name="submit">
> > </form>
> >
> > </body>
> > </html>
> >
> > <!-- simple.php -->
> > <HTML>
> > <body>
> > <?php
> > if (!$wName || !$wEmail )
> > {
> > echo "You have not entered all the required details.<br>"
> > ."Please go back and enter data in all fields.<br>";
> > echo ".$wName., .$wEmail.";
> > exit;
> > }
> > ?>
> > </body>
> > </HTML>
> >
> > <!-- here is the output from the above code -->
> >
> > You have not entered all the required details.
> > Please go back and enter data in all fields.
> > .., ..
>
> I suppose you entered a Name and Email in sample.html, send it off, and
> then got the error...
> The problem is probably that your server has "register_globals" set to
> "Off", which all new PHP distributions have. That means the $wName and
> $wEmail variables are not available for the simple.php script. You will
> have to use the $_POST variables to get them.
> To fix this problem, just replace $wName and $wEmail with $_POST['wName']
> and $_POST['wEmail'].
>
> DrTebi
|