Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2011
    Posts
    77
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Getting username variable to display Welcome message issue

    I'm using php designer 7 and am still getting a syntax error in my variable so its not working. Any ideas?

    Code:
    <?php
    
    $username = $_POST['username']; (Getting error on this line)
    
    echo 'Welcome $username';
    
    ?>
    Last edited by rexhvn; 11-01-2012 at 10:56 AM.

  2. #2
    New Coder
    Join Date
    Sep 2011
    Posts
    85
    Thanks
    0
    Thanked 7 Times in 7 Posts
    You need 'Welcome ' . $username;

    or

    "Welcome $username"
    Last edited by davidjones1990; 11-01-2012 at 09:19 AM. Reason: type o

  3. #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    9
    Thanks
    0
    Thanked 1 Time in 1 Post
    One more thing, you do no put name="username" inside the form tag.

  4. #4
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    9
    Thanks
    0
    Thanked 1 Time in 1 Post
    One more thing, you do no put name="username" inside the form tag.

  5. #5
    New Coder
    Join Date
    Oct 2011
    Posts
    77
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi guys,

    i'm getting a syntax error, so its not working. Any ideas?

    Code:
    <?php
    $username = $_POST['username']; (getting error here)
    
    echo 'Welcome'.$username ;
    
    ?>

  6. #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    17,027
    Thanks
    4
    Thanked 2,668 Times in 2,637 Posts
    You'll get a syntax error on T_STRING if you have that (getting error here) in the code. Otherwise, there is no syntactical error.
    You will get a E_NOTICE on accessing $_POST['username'] if it doesn't exist. That will only exist if you posted from a form, so you should check it first:
    PHP Code:
    if (isset($_POST['username']))
    {
        
    printf('Welcome back %s'$_POST['username']);



 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •