please am a beginner. i have been trying to send data to a php script using a html form through get and post methods, whenever i submit the html form the script comes empty.i have changed register_global in php ini from of to on.its still not working.
Turn off register globals again, it’s a major security risk! Then post your code, hard to help if we don’t know what you do.
Basically a form can submit with either get or post. You use these variables with
$_GET[‘fieldname’] or $_POST[‘fieldname’]
the html form is
[php]
username:
Email address:
while the php script is
[php]
A simple response Welcom, <?php echo $_POST["user"]; ?>! Your E-mail address is: <?php echo $_POST["email address"]; ?> [/php]i tried and it didnt work
You send in the fields “username” and “email address”
Then you try to use “user” and “email address”, so immidiatly we see that username != user, and it will not work.
The email address field however isn’t that obvious
[hr]
If you add this to the top of example.php it will reveal its secrets
[php]<?php
echo ‘
’;
var_dump($_POST);
?>[/php]Output:
array(2) { 'username' => string(10) "nameasfafs" 'email_address' => string(11) "emailasgsag" }
So you see, sending parameters with spaces isn’t well supported, so it chooses to automagically replace spaces with underscores.
Best practice would be to not send in variable names with spaces. So change to this:
[php]
[/php]
username:
Email address:
[php]
A simple response Welcom, <?php echo $_POST["username"]; ?>! Your E-mail address is: <?php echo $_POST["email"]; ?> [/php]
I have just tried what you suggested but it still didnt work. Dont you think it has something to do with my .htaccess files cos thats a suggestion i have seen on online post. Although i have tried that too but its no good, i dont know if it has to do with my settings.Thanks in advance for your responses
Post the code you have now