...

View Full Version : Getting username variable to display Welcome message issue



rexhvn
11-01-2012, 04:21 AM
I'm using php designer 7 and am still getting a syntax error in my variable so its not working. Any ideas?



<?php

$username = $_POST['username']; (Getting error on this line)

echo 'Welcome $username';

?>

davidjones1990
11-01-2012, 09:19 AM
You need 'Welcome ' . $username;

or

"Welcome $username"

chrislim2888
11-01-2012, 09:26 AM
One more thing, you do no put name="username" inside the form tag.

chrislim2888
11-01-2012, 09:26 AM
One more thing, you do no put name="username" inside the form tag.

rexhvn
11-01-2012, 10:58 AM
Hi guys,

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



<?php
$username = $_POST['username']; (getting error here)

echo 'Welcome'.$username ;

?>

Fou-Lu
11-01-2012, 04:59 PM
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:


if (isset($_POST['username']))
{
printf('Welcome back %s', $_POST['username']);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum