Beginner's help

Ok, I am learning to code reading this tutorial and I believe I’m doing OK so far but I’ve hit a brick wall!

[php]<?PHP

$username = $_POST[‘username’];

if ($username = = “letmein”) {
print (“Welcome back, friend!”);
}
else {
print (“You’re not a member of this site”);
}

?>[/php]

What is wrong with this? This is infact code from the tutorial but it has errors and doesn’t work. Why?

try this instead… Replace Print withecho “”;

Either print() or echo will work…

The problem is the space between your "="s. Everything else looks good, minus some minor coding standard changes.

[php]

<?php //use lowercase php tags //$username = $_POST['username']; Renaming variables are redundant if ($_POST['username']== "letmein") { //print ("Welcome back, friend!"); echo 'Welcome back, friend!'; //Use single-quotes instead of double-quotes unless you need to evaluate the string for variables } else { //print ("You're not a member of this site"); echo 'You\'re not a member of this site'; }[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service