logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 03-19-2012, 08:27 PM   #1
sydesign
 
Join Date: Jan 2011
Posts: 41
Default Using the echo language construct

I'm pretty new to php and still am not understanding some things.

I am going through a tutorial on making a membership log-in system i got it working mostly. the issue I'm having now is that the way the tutorial was set up is that when a user is logged in it echoes out a message "welcome user" or something like that. however i would like to have it echo out the webpage i have already created. i looked it up and saw that you can't add quotes within the echo string. is there another way i can have the echo statement show the webpage without me having to input the html (and fix all the quotes) after within the string?

the code i have right now is

PHP Code:
<?php
error_reporting 
(E_ALL E_NOTICE );
session_start();
$userid $_SESSION['userid'];
$username $_SESSION['username'];


if (
$username && $userid){
    echo 
"Welcome Sydesign!";
    
}
else
    echo 
"Please login to access this page. <a href='../login.php'>Login here</a>";

?>
where it says "Welcome Sydesign!" i want it to display the webpage i already created. I'm sure there are many other ways to do this and I'm open to anything i just want to learn how to do it right.

thank you so much for any help.
sydesign is offline   Reply With Quote
Old 03-20-2012, 02:50 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,175
Default

it might be simpler to use location to redirect if they are logged in try this (edit the page name of course )

Code:
<?php
error_reporting (E_ALL ^ E_NOTICE );
session_start();
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];


if ($username && $userid){
   header( 'Location: http://www.yoursite.com/new_page.html' ) ;
    
}
else
    echo "Please login to access this page. <a href='../login.php'>Login here</a>";

?>
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 03-20-2012, 06:23 PM   #3
sydesign
 
Join Date: Jan 2011
Posts: 41
Default

okay thank you. I got it to work finally. Figured out how to make a heredoc statement work and it seems to be working fine for now. But that will be good to know for the further thank you!
sydesign is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:41 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com