rdkd1970 Posted May 5, 2011 Share Posted May 5, 2011 Welcome member. I am able to get data added to my db and when it gets to the welcome page I want it to welcome $firstname but it comes up blank. How can I fix my echo statement. <?php session_id(); session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome</title> </head> <body> <?php /* Program: New_member.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ if (@$_SESSION['auth'] != "yes") @include('Connections/connect_to_mysql.php'); $result = mysql_query("SELECT firstname FROM `Members` WHERE id='{$_SESSION['id']}'"); $row = mysql_fetch_array($result); echo "<html> <head><title>New Member Welcome</title></head> <body> <h2 style='margin-top: .7in; text-align: center'> Welcome, $firstName </h2>\n"; ?> <p>Your new Member accounts lets you enter the members only section of our web site. You'll find special discounts, a profile of matches, live advise for experts, and much more.</p> <p>Your new Member ID and password were emailed to you. Store them carefully for future use.</p> <div style="text-align: center"> <p style="margin-top: .5in; font-weight: bold"> Glad you could join us!</p> <form action="profile.php" method="post"> <input type="submit" value="Enter the Members Only Section"> </form> <form action="index.php" method="post"> <input type="submit" value="Go to Main Page"> </form> </div> </body> </html> :-\ Quote Link to comment https://forums.phpfreaks.com/topic/235579-echo-statement/ Share on other sites More sharing options...
phppaper Posted May 5, 2011 Share Posted May 5, 2011 if (@$_SESSION['auth'] != "yes") <--- meaning = no; means not authorizes? Logical error? brackets after if? $firstName should be $row['firstname'] Quote Link to comment https://forums.phpfreaks.com/topic/235579-echo-statement/#findComment-1210814 Share on other sites More sharing options...
rdkd1970 Posted May 5, 2011 Author Share Posted May 5, 2011 Are you saying it should be written with "no" instead of the "yes" if (@$_SESSION['auth'] != "yes") Quote Link to comment https://forums.phpfreaks.com/topic/235579-echo-statement/#findComment-1210854 Share on other sites More sharing options...
cssfreakie Posted May 5, 2011 Share Posted May 5, 2011 Are you saying it should be written with "no" instead of the "yes" if (@$_SESSION['auth'] != "yes") yes he means that != means 'is not equal too" it's the opposite of == which means "equal too" more info here: http://www.php.net/manual/en/language.operators.comparison.php so your statement actually says if the value of session[auth] is not equal to yes,... than say 'hello', while you want the complete opposite. Also the use of brackets can increase the readability of your script for yourself and others. assuming you work in a development environment remove the @ signs (error suppressors), and place the following above your script. <?php error_reporting(E_ALL); ini_set("display_errors", 1); ?> another thing, where does $firstName get it's value from? Quote Link to comment https://forums.phpfreaks.com/topic/235579-echo-statement/#findComment-1210876 Share on other sites More sharing options...
rdkd1970 Posted May 5, 2011 Author Share Posted May 5, 2011 <?php error_reporting(E_ALL); ini_set("display_errors", 1); ?> if(@$_SESSION['id'] == "yes") Is that correct. I am not sure what would go in the brackets???? sorry I am so new at this but I love this scripts it is the best I am socking up all this knowledge. Quote Link to comment https://forums.phpfreaks.com/topic/235579-echo-statement/#findComment-1210878 Share on other sites More sharing options...
cssfreakie Posted May 5, 2011 Share Posted May 5, 2011 next time if you post code try out the bbcode code tags marked in the editor with a #sign a normal if statement would look like this: $name = 'john'; //setting a variable; if($name == 'john'){ // condition, is name equal to lower case 'john' notice we use == and not = echo "hello $name"; }else{// so incase the condition is not as expected echo "sorry you are not john"; } See the brackets, inside them you put the events that should happen ones a condition is or is not as expected. and again remove that @ sign it's an error suppressor and when developing we need errors in order to know what we do wrong. Quote Link to comment https://forums.phpfreaks.com/topic/235579-echo-statement/#findComment-1210882 Share on other sites More sharing options...
rdkd1970 Posted May 5, 2011 Author Share Posted May 5, 2011 Got it. I am so thankful. Quote Link to comment https://forums.phpfreaks.com/topic/235579-echo-statement/#findComment-1210886 Share on other sites More sharing options...
cssfreakie Posted May 5, 2011 Share Posted May 5, 2011 Got it. I am so thankful. pictures or i don't believe it you can mark it solved too if you find that a bit too much. (left bottom of the screen) Quote Link to comment https://forums.phpfreaks.com/topic/235579-echo-statement/#findComment-1210887 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.