Jump to content


Photo

If($_POST['submit'])


  • Please log in to reply
9 replies to this topic

#1 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 03 October 2006 - 03:52 PM

Hi,

On my processing pages... should i use

If($_POST['submit'])

all the time or does it not matte?

#2 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 03 October 2006 - 03:55 PM

if you are testing to see if a form as been posted you need to test as follows

if (isset($_POST['submit']))
{
// do what ever here if the form has been submited
}


#3 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 03 October 2006 - 03:56 PM

You should check any variable exists before you use it.

if (isset($_POST['submit'])) {


#4 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 03 October 2006 - 03:59 PM

at the mo my say login_process.php script is....

$session_start();

$username = $_GET['username'];
$email = $_GET['email'];
$image= $_GET['mage'];

so to make script better should i put the

if (isset($_POST['submit'])) {

$username = $_GET['username'];
$email = $_GET['email'];
$image= $_GET['mage'];

}


#5 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 03 October 2006 - 04:04 PM

Yes. But you should also check the other before using them. The turnary operator is great in this siuation....

$username = $_GET['username'] ? $_GET['username'] : "";
$email = $_GET['email'] ? $_GET['email'] : "";
$image = $_GET['mage'] ? $_GET['mage'] : "";


#6 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 04 October 2006 - 12:27 PM

$username = $_GET['username'] ? $_GET['username'] : "";

can you explain what this actually means please?

#7 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 04 October 2006 - 12:34 PM

$username = $_GET['username'] ? $_GET['username'] : "";

can you explain what this actually means please?


it's another way to write this:
<?php
// instead of this:
if (isset($_GET['username'])) $username = $_GET['username'];
else $username = '';

// just do this:
$username = isset($_GET['username']) ? $_GET['username'] : '';
?>

read up on the ternary operator in the PHP manual for more info
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#8 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 04 October 2006 - 01:15 PM

"read up on the ternary operator in the PHP manual for more info"

u got a link to this info please...

#9 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 04 October 2006 - 01:16 PM

"read up on the ternary operator in the PHP manual for more info"

u got a link to this info please...


really tough: http://www.php.net/ternary ;)
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#10 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 04 October 2006 - 01:19 PM

thanks very much...





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users