Jump to content

how do i add a default name if none was given


the-botman

Recommended Posts

hi guys..

 

i need to know how to add a default name if users do not add name to my logo gen

 

i was thinking about using an if statment here

session_start(); 
   $_SESSION['number'] = $_POST['number'];
   $_SESSION['name'] = $_POST['name'];
   $_SESSION['image'] = $_GET['image'];

 

Link to comment
Share on other sites

php5.3

session_start();
$_SESSION['number']  =  $_POST['number'];
$_SESSION['name']  =  $_POST['name'] ?: 'some default';
$_SESSION['image']  =  $_GET['image'];

 

else

 

session_start();
$_SESSION['number']  =  $_POST['number'];
$_SESSION['name']  =  $_POST['name'] ? $_POST['name'] : 'some default';
$_SESSION['image']  =  $_GET['image'];

Link to comment
Share on other sites

thanks guys that works great its just 1 issue i have no when a user adds text it puts the text in the center but when the user does not it adds te default text but not in the center any idea what i can do about this?

Link to comment
Share on other sites

$_SESSION['name']  =  $_POST['name'] ?: 'some default';

 

I think is best not used as it will spread confusion, not many read the manual as thoroughly as we are :)

 

Spread confusion? Amongst who? The people who don't know the language well enough to understand it?

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.