Jump to content

If($_POST['submit'])


brown2005

Recommended Posts

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'];

}
Link to comment
Share on other sites

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

[code=php:0]
$username = $_GET['username'] ? $_GET['username'] : "";
$email = $_GET['email'] ? $_GET['email'] : "";
$image = $_GET['mage'] ? $_GET['mage'] : "";
[/code]
Link to comment
Share on other sites

[quote author=brown2005 link=topic=110381.msg446603#msg446603 date=1159964853]
$username = $_GET['username'] ? $_GET['username'] : "";

can you explain what this actually means please?
[/quote]

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

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

read up on the ternary operator in the PHP manual for more info
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.