-
[RESOLVED] help
i dont no wats wrong with these code samples...
Code:
session_name ('User');
session_start();
$_SESSION['username'] = 'testing';
$_SESSION['loggedin'] = time();
header ('Location: http://$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/welcome.php');
exit ();
} else {
echo '<p>The submittes username and password do not match those on file.<br />
Go back and try again.</p>';
and
Code:
<?php
session_start();
require ('header.php');
echo '<h3>Welcome to Distorted View, ' . ucfirst($_SESSION['username']) . '!</h3>;
echo '<p>You have been logged in since:<br /> ' . date ('g:i a', $_SESSION['loggedin']) . '</p>';
echo '<p><a href="logout.php" title="Log Out">Log Out</a></p>';
require ('footer.php');
?>
they both contain parse errors ( an unexpected T_STRING error in the first where the header (line 15ish)i s and an unexpected '>' in the second one (line 7ish))
-
Re: help
Been a while since I did any PHP :)
Your problem seems to be where you are referencing your arrays while 'inside' a string.
You have the line
'Location: http://$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/welcome.php'
Which really needs to be
'Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/welcome.php'
This is because the ' character begins and ends your string. Hence your problem :)
The problem with your second example is quote marks.
echo '<p><a href="logout.php" title="Log Out">Log Out</a></p>';
Might I recommend you use a syntax hightligher for PHP. This will make it clear where you begin and end a string, and highlight syntax errors.
Good Luck!
-
Re: help
it says the problem is on line 7 for the second one... this is line 7
echo '<p>You have been logged in since:<br /> ' . date ('g:i a', $_SESSION['loggedin']) . '</p>';
the first one worx now thanx but the second is still weird
-
Re: help
Ah look here is the problem :0
echo '<h3>Welcome to Distorted View, ' . ucfirst($_SESSION['username']) . '!</h3>;
You do not terminate the string after </H3>;
A syntax highlighter would have shown this problem !!
-
Re: help
so wat should it be? sry im new
-
Re: help