Page 1 of 1

not sure where error is coming from

Posted: Sat Nov 12, 2005 7:24 pm
by bruceg
I am getting this:

Parse error: parse error, unexpected T_STRING in /hsphere/local/home/bruceg/inspired-evolution.com/Admin_Contacts.php on line 7

for the below code. Can someone point out the error for me?

thanks!!!

Code: Select all

<?
//start a session
session_start() ;
//check if user is coming from a form
if  ($POST[op] =="ds") {
		//check username and password
		if (($_POST[username] != "admin") || ($_POST[password] !="abc123")) {
		//handle bad login
		$msg ="<p><font color="red"><strong>Bad Login - Try Again</strong></p>";
		$show_form = "yes";
} else {
		//handle good login
		$_SESSION[valid] = "yes";
		$show_menu ="yes";
		}
} else {
			//determine what to show
			if ($valid == "yes") {
				$show_menu = "yes";
			} else {
				$show_form = "yes";
			}
}
//build form block
$form_block = "<h1>Login</h1>
<form method=POST action=\"$_SERVER[PHP_SELF]\">
$msg
<p><strong>username:</strong><br />
<input type=\"text\" name=\"username\" size=15 maxlength=25></p>
<p><strong>password</strong><br />
<input type=\"password\" name=\"password\" size=15 maxlength=25></p>
<input type=\"hidden\" name=\"op\" value=\"ds\">
<p><input type=\"submit\" name=\"submit\" value=\"login\"></p>
</form>";
//build menu block
$menu_block = "<h1>My Contact Administration System</h1>
<p><strong>Administration</strong></p>
<ul>
<li><a href=\"show_addcontact.php\">Add a Contact</a></li>
<li><a href=\"pick_moddcontact.php\">Modify a Contact</a></li>
<li><a href=\"pick_delcontact.php\">Delete a Contact</a></li>
</ul>
<p><strong>View Records</strong></p>
<ul>
<li><a href=\"show_contactsbyname.php\">Show Contacts, Ordered by Name</a>
</ul>";
//assign the block to show the $display_block variable
if ($show_form == "yes") {
	$display_block = $form_block;
	} else if ($show_menu == "yes") {
		$display_block = $menu_block;
}
?>
<html>
<head>
<title>My Contact Management System</title>
</head>
<body>
<? echo "$display_block"; ?>
</body>
</html>

Posted: Sat Nov 12, 2005 7:28 pm
by sheila

Code: Select all

$msg ="<p><font color="red"><strong>Bad Login - Try Again</strong></p>";
The double quotes in the HTML is the problem. Either of the following will work.

Code: Select all

$msg ="<p><font color='red'><strong>Bad Login - Try Again</strong></p>"; 

        $msg ='<p><font color="red"><strong>Bad Login - Try Again</strong></p>';

Posted: Sat Nov 12, 2005 7:56 pm
by bruceg
great, thanks :-)