Help: a problem with $_POST & $_GET[]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RedMad
Forum Newbie
Posts: 2
Joined: Fri Mar 18, 2011 4:20 pm

Help: a problem with $_POST & $_GET[]

Post by RedMad »

Hi :) ..iam an IT student so i'm trying to develop my skills in php
i have a problem with $_POST[] & $_GET[] the both don't work when submitting the form for example :

this is the HTML Code :

Code: Select all

<html>
    <head>
        
        <title>Test</title>
    </head>
    <body>
        <form method="post" action="index.php">
            <fieldset>
                <legend>Enter Date</legend>
            First Name:<input type="Text" name="FirstName"/><br/>
            Last Name:<input type="Text" name="LastName"/><br/>
            <input type="submit" value="Submit"/>
            </fieldset>
        </form>
    </body>
</html>

and in the index.php this is the code :

Code: Select all

        
        <?php
      
      
       $Fname=$_POST['FirstName'];
       $LName=$_POST['LastName'];

       $FullName=$Fname.' '.$LName;




       echo $FullName;

/* i used before the one above the following code :

echo $_POST['FirstName'].'  '.$_POST['LastName'];
but it didn't work.
*/
        ?>
1-i'm using PHP 5.3.5 and Server version: Apache/2.2.17 (Unix)
2-in the php.ini i modified the register_globals and put the value: On -but no result.
3- and after 3 hours of searching without any reasult : i modified the register_long_arrays to : On -even it don't solve my problem :D
and post_max_size already = 8M


4- i checked the variables_order and yes it has the value of : "GPCS" and about the request_order it has the value "GP".

5-some people on the web was talking about mod_bandwidth i didn't find it in the httpd.conf !!they said it should be disabled or or or ..etc..

after 5 hours i used another code to test it :D i quoted it from a book this is the code -it didn't work too

Code: Select all

<html>
<head><title>Register</title></head>
<body>
<?php
if (!isset ($_POST['register']) ||($_POST['register'] !='Register')) {
?>

<h1>Registration</h1>
<form method="get" action="register.php">
<table>
<tr><td>E-mail address:</td>
<td><input type='text' name='email'/></td></tr>
<tr><td>First name:</td>
<td><input type='text' name='first_name'/></td></tr>
<tr><td>Last name:</td>
<td><input type='text' name='last_name'/></td></tr>
<tr><td>Password:</td>
<td><input type='password' name='password'/></td></tr>
<tr>
<td colspan='2'>
<input type='submit' name='register' value='Register'/>
</td>
</tr>
</table>
</form>
<?php
} else {
?>
E-mail: <?php echo $_POST['email']; ?><br />
Name: <?php echo $_POST['first_name']. ' '. $_POST['last_name'];
?><br />
Password: <?php echo $_POST['password']; ?><br />
<?php
}
?>
</body>
</html>

all what i got from both codes were blank page ...

thank you all :)[/size]
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Re: Help: a problem with $_POST & $_GET[]

Post by litebearer »

Being that we have no real knowledge of the level of your skills, we'll start with some easy basic steps to isolate your problem...

1. create a file named test1.php

Code: Select all

<?PHP
phpinfo();
?>
point your browser to that file and see what it does.

2. create a file named test2.php

Code: Select all

<?PHP
?>
<a href="test3.php?hisname=sam"> click me</a>
<?PHP
?>
create a file named test3.php

Code: Select all

<?PHP
$hisname = $_GET['hisname'];
echo $hisname;
echo "HERE";
?>
point your browser to test2.php and see what happens
Tell us the results
RedMad
Forum Newbie
Posts: 2
Joined: Fri Mar 18, 2011 4:20 pm

Re: Help: a problem with $_POST & $_GET[]

Post by RedMad »

litebearer wrote:Being that we have no real knowledge of the level of your skills, we'll start with some easy basic steps to isolate your problem...

1. create a file named test1.php

Code: Select all

<?PHP
phpinfo();
?>
point your browser to that file and see what it does.

2. create a file named test2.php

Code: Select all

<?PHP
?>
<a href="test3.php?hisname=sam"> click me</a>
<?PHP
?>
create a file named test3.php

Code: Select all

<?PHP
$hisname = $_GET['hisname'];
echo $hisname;
echo "HERE";
?>
point your browser to test2.php and see what happens
Tell us the results


thank you mr...my skills ?i'm not professional first time i used php was in 2005 for 7 monthes then stoped using it (our university wasn't support it thats time !!) ..now i back to find it another language !!
thanks for your help i'll share the solution here because i find it while trying to fix my problem..
all the configurations have mentioned above in the first post are NOT correct except that the variables_order="GPCS" not a matter what is the order some files maybe have another ordering and post_max_size already = 8M this is the default configuration and will work register_globals should NOT be On this is not secure and register_long_arrays=Off.

now i'm using localhost server the problem in using the concept of relative addresses like : if both files are in the same directory we don't need to use the full path.. but this was wrong in calling a php document as we poin our browser like : http://localhost/yourDoc.php we should use it with the form in the action part like this :

action="http://localhost/index.php"... in my example above was index.php
this is the last step i didn't do before asking and while i was searching for a solution yesterday many people have the same mistake..
Thank you again -btw i tested your code :)
Post Reply