registration process error

my registration code showing error aftr executing , the code is given below and i am using the wamp server,

<?php echo "

Register

"; $submit = $_POST['submit']; $fullname = $_POST['fullname']; $username = $_POST['username']; $password = $_POST['password']; $repeatpassword = $_POST['repeatpassword']; if ($submit) { echo "$username/$password/$repeatpassword/ $fullname"; } ?>
      <tr>
           <td>
            Choose a username:
            </td>
           <td>
           <input type='text' 

name=‘username’>

      <tr>
           <td>
             Choose a password:
            </td>
           <td>
           <input type='password' 

name=‘password’>

      <tr>
           <td>
             Repeat your password:
            </td>
           <td>
           <input type='password' 

name=‘repeatpassword’>


Your full name: <input type='text'

name=‘fullname’>

<input type='submit' name='submit'

value=‘submit’>

cud any1 please help regarding the same the error which is occuring are ( ! ) Notice: Undefined index: submit in C:\wamp\www\loginsession\register.php on line 6 Call Stack # Time Memory Function Location 1 0.0013 366768 {main}( ) ..\register.php:0

( ! ) Notice: Undefined index: fullname in C:\wamp\www\loginsession\register.php on line 8
Call Stack

Time Memory Function Location

1 0.0013 366768 {main}( ) …\register.php:0

( ! ) Notice: Undefined index: username in C:\wamp\www\loginsession\register.php on line 9
Call Stack

Time Memory Function Location

1 0.0013 366768 {main}( ) …\register.php:0

( ! ) Notice: Undefined index: password in C:\wamp\www\loginsession\register.php on line 10
Call Stack

Time Memory Function Location

1 0.0013 366768 {main}( ) …\register.php:0

( ! ) Notice: Undefined index: repeatpassword in C:\wamp\www\loginsession\register.php on line 11
Call Stack

Time Memory Function Location

1 0.0013 366768 {main}( ) .

hello imnaina11, do the below changes 1. remove $submit = $_POST['submit']; replace below code if ($submit) { echo "$username/$password/$repeatpassword/ $fullname"; }

with below code

if(REQUEST_METHOD == ‘POST’)
{
echo $username.’
’.$password.’
’.$repeatpassword.’
’.$fullname;
}

i hope this will helpful for you…
SR

@ Sarthak:
its agn shwing error as …

( ! ) Notice: Use of undefined constant REQUEST_METHOD - assumed ‘REQUEST_METHOD’ in C:\wamp\www\loginsession\register.php on line 6
Call Stack

Time Memory Function Location

1 0.0006 367960 {main}( ) …\register.php:0
and my modified code acc to u is

<?php echo "

Register

"; if(REQUEST_METHOD == 'POST') { echo $username.'
'.$password.'
'. $repeatpassword.'
'.$fullname; } ?>
      <tr>
           <td>
            Choose a username:
            </td>
           <td>
           <input type='text' 

name=‘username’>

      <tr>
           <td>
             Choose a password:
            </td>
           <td>
           <input type='password' 

name=‘password’>

      <tr>
           <td>
             Repeat your password:
            </td>
           <td>
           <input type='password' 

name=‘repeatpassword’>


Your full name: <input type='text'

name=‘fullname’>

<input type='submit' name='submit'

value=‘submit’>

hello imnaina11, i did a small mistake in my previous post please try below code.

if($REQUEST_METHOD == ‘POST’)
{
echo $username.’
’.$password.’
’.$repeatpassword.’
’.$fullname;
}

i forget to put $ sign before REQUEST_METHOD.
i hope this will helpful for you.
SR

still showing error :::

( ! ) Notice: Undefined variable: REQUEST_METHOD in C:\wamp\www\loginsession\register.php on line 4
Call Stack

Time Memory Function Location

1 0.0006 364520 {main}( ) …\register.php:0

Where do you set the variable $REQUEST_METHOD??? There is no such function in PHP!

Perhaps you mean that you want to see if the current page was sent by the POST method. ???

If so, you need to use it this way: $_SERVER[‘REQUEST_METHOD’]

$_SERVER is a valid array of items from the server, one of which is the “REQUEST_METHOD”…

Hope that helps…

hello imnaina11, use below code i have successfully execute it. save below code as register.php and execute it. [php] <? if($REQUEST_METHOD == 'POST') { echo '**********
following detail is filled by user
'; echo ''.$username.'
'.$password.'
'.$repeatpassword.'
'.$fullname.'
'; echo '

**************'; } ?>
Your full name:
Choose a username:
Choose a password:
Repeat your password:

[/php]

@ErnieAlex here i am using $REQUEST_METHOD which is providing correct result. One more thing regarding $REQUEST_METHOD it is used for checking the method of form posted.
i hope you are getting my point.
I this will helpful for imnaina11.
SR

Well, Sarthak, maybe it IS working for now, but, there is no $REQUEST_METHOD function listed anywhere that I could find in any PHP manual. I do not see where this “variable” is set in his code. Although, I may have missed it. As far as I can see, if($REQUEST_METHOD == ‘POST’) compares a variable to ‘POST’, it does not compare the server’s request method. ( $_SERVER[‘REQUEST_METHOD’]==‘POST’ )

Please explain what I am missing. Thanks!

well ErnieAlex, i am agree with you that there is no $REQUEST_METHOD function listed anywhere in any PHP manual. But i am generally you this syntax for just checking that the data submitted by form is coming from POST or GET method instead of checking the value of submit button.
see here

when this button is click the form will be submit. than instead of checking this type
if($_POST[‘submit’] == ‘send’)
{
//place your code
}
it’s always better to use
if($REQUEST_METHOD == ‘POST’)
{
//place your code
}

Note: it’s all depend on you, what logic you prefer to use. Here i am just suggesting you not necessary to do this.

i hope you are getting my point.
SR

I understand your point, Sarthak, but, I just do not see where he declares $REQUEST_METHOD. So, I do not see how you can compare it to a value without it ever being set. It will always give a false value.
if($REQUEST_METHOD(nothing)==“something”) always zero!

Unless I am not seeing all of his code. But, either way, if it works, don’t fix it… Ernie

Sponsor our Newsletter | Privacy Policy | Terms of Service