PHP [solved]

  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

PHP Code: [ Select ]
 
$loginvars = array (
 
'submit' => '$_POST['submit']'
 
);
  1.  
  2. $loginvars = array (
  3.  
  4. 'submit' => '$_POST['submit']'
  5.  
  6. );


Now the above array doesnt work because there are quotations inside it....

What other methods can i use?1
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

how about this?

PHP Code: [ Select ]
 
'submit' => ''.$_POST['submit'].'',
 
 
  1.  
  2. 'submit' => ''.$_POST['submit'].'',
  3.  
  4.  
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

PHP Code: [ Select ]
 
'submit' => $_POST['submit'],
 
 
  1.  
  2. 'submit' => $_POST['submit'],
  3.  
  4.  

Which will do the same as the second version you posted.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

but, it will think its meant to do 'submit' only....

I tried the method you have mentioned...
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

i have even tried:

[php]
'submit' => '$_POST['.'submit'.']';
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

are you trying to get the contents of the variable $_POST['submit'] or the string literal into that variable?

IE if the value of $_POST['submit'] = "hello" do you want hello or $_POST['submit'] to go into the array??

Quote:
but, it will think its meant to do 'submit' only....

I tried the method you have mentioned...
I have no idea what this means :?
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

To improve on security (well its what i think) i created a php called "functions.php".

This has arrays like:

PHP Code: [ Select ]
 
$loginvars = array (
 
'submit' => ''.$_POST['submit'].'',
 
'user' => ''.$_POST['user'].'',
 
'pass' => ''.$_POST['.pass'].''
 
);
 
 
  1.  
  2. $loginvars = array (
  3.  
  4. 'submit' => ''.$_POST['submit'].'',
  5.  
  6. 'user' => ''.$_POST['user'].'',
  7.  
  8. 'pass' => ''.$_POST['.pass'].''
  9.  
  10. );
  11.  
  12.  


So when it comes to validating the form....

PHP Code: [ Select ]
 
include "../req/functions.php";
 
if (isset($loginvars['submit'])) {
 
 
 
 
 
if ( $loginvars['user'] == "" ) { $uerror = $loginerrors['nouser']; }
 
if ( $loginvars['pass'] == "" ) { $uerror = $loginerrors['nopass']; }
 
if ( $loginvars['user'] == "" || $loginvars['pass'] == "" ) { $uerror = $loginerrors['noinput']; }
 
 
 
}
 
 
  1.  
  2. include "../req/functions.php";
  3.  
  4. if (isset($loginvars['submit'])) {
  5.  
  6.  
  7.  
  8.  
  9.  
  10. if ( $loginvars['user'] == "" ) { $uerror = $loginerrors['nouser']; }
  11.  
  12. if ( $loginvars['pass'] == "" ) { $uerror = $loginerrors['nopass']; }
  13.  
  14. if ( $loginvars['user'] == "" || $loginvars['pass'] == "" ) { $uerror = $loginerrors['noinput']; }
  15.  
  16.  
  17.  
  18. }
  19.  
  20.  


I heard its not safe to directly pass form variables... So i use this type of function...
After i solve this i need a way to delete form variables :|
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

PHP Code: [ Select ]
 
$loginvars = array (
 
'submit' => $_POST['submit'],
 
'user' => $_POST['user'],
 
'pass' => $_POST['.pass']
 
);
 
 
  1.  
  2. $loginvars = array (
  3.  
  4. 'submit' => $_POST['submit'],
  5.  
  6. 'user' => $_POST['user'],
  7.  
  8. 'pass' => $_POST['.pass']
  9.  
  10. );
  11.  
  12.  

That should work :? if it doesn't work what errors do you get? Try Doing that and then print_r($loginvars), see what it outputs.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

http://dhost.info/gmforum/rethink/req/test.php I didnt test it first, i wanted to see the output.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

i have now tried:

PHP Code: [ Select ]
 
<?PHP
 
$loginvars = array (
 
'submit' => '$_POST['.'submit'.']',
 
'user' => '$_POST['.'user'.']',
 
'pass' => '$_POST['.'pass'.']'
 
);
 
 
 
echo $loginvars['submit'];
 
 
 
?>
 
 
  1.  
  2. <?PHP
  3.  
  4. $loginvars = array (
  5.  
  6. 'submit' => '$_POST['.'submit'.']',
  7.  
  8. 'user' => '$_POST['.'user'.']',
  9.  
  10. 'pass' => '$_POST['.'pass'.']'
  11.  
  12. );
  13.  
  14.  
  15.  
  16. echo $loginvars['submit'];
  17.  
  18.  
  19.  
  20. ?>
  21.  
  22.  


and it shows@

Quote:
$_POST[submit]
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

rtm, it was my fault...

I put in the wrong names for the $_POSt variables

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 21 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.