Page 1 of 1

problem running php on apache (xampp) after new install

PostPosted: 31. May 2010 05:50
by Duke555
how are you?
i just wanted to ask you what to do in the following situation.
I have a code (see below) that worked fine on someone's xampp on linux. i installed xampp (on windows xp) on my machine
and instead of a normal output i get the following (see immediadtely below). how do i resolve it?

thank you :)
======
* Home
*
*


You must register first below in order to access member-only area of the site.

'; } ?>

Please complete a registration form below in order to shop on our site

Registration form:
Email address: <? //if there was no error only
Please include a valid email address and/or name'; } ?>
Name: <? //if there was no error onl

* Register
* Products
* My Shopping Cart
Welcome, email address.
Feel free to browse our Products and My Cart sections of the site.
Not registered under ? Click here


===========
<php?
//start output buffer to avoid issues with the header()
ob_start();
//include the header template
include("header.html");
//require all the necessary files
//include("register.php");

//if user requested to 'forget' previous signin and/or user wishes to register (again) then...
if (isset($_GET['delete_cookie'])) {
setcookie('email','', time()-3600, '/', '', 0, 0); //delete $_COOKIE['email']
setcookie('name','', time()-3600, '/', '', 0, 0); //delete $_COOKIE['name']

echo "Logging out...";
//transfer to the index.php for unregistered users
$url = "http://".$_SERVER['HTTP_HOST']."/index.php";
header("Location: ".$url);
}
//if user has not registered before then...
if(!isset($_COOKIE['email']))
{
?>
<div id="navigation">
<ul>
<li><a href="index.php" class="active">Home</a></li>
<li></li>
<li></li>
</ul>
</div>
<div id="content">
<?
if ($_GET['error'] == "1") {
$error_code = 1; //this means that there's been an error and we need to notify the customer
}
if ($_GET['error'] == "2") {
$error_code = 2; //this means that there's been an error and we need to notify the customer
}
?>
<br>
<?
if ($error_code == 2) {
echo '<p class="error">You must register first below in order to access member-only area of the site.</p>';
}

?>
<p>Please complete a registration form below in order to shop on our site</p>

<p>Registration form:</p>
<form method=GET action="register.php">
<table>
<tr>
<td align=right>
Email address:
</td><td align=left>
<input type=text size=25 name="email" value="<?
//if there was no error only then output email address
if(!$error_code)
{
echo $_GET['email'];
}
?>">
<?

// if email address/name provided by the user is invalid (in which case error code is == to 1) THEN ...
if ($error_code==1)
{
//output an error message
echo '<b class="error">Please include a valid email address and/or name</b>';
}
?>
</td>
</tr>
<tr>
<td align=right>
Name:
</td><td align=left>
<input type=text size=25 name="name" value="<?
//if there was no error only then output email address
if(!$error_code)
{
echo $_GET['name'];
}
?>">
</td>
</tr>
<TR>
<TD colspan=2 align=center>
<input type=submit value="SUBMIT">
</TD></TR>
</TABLE>
</form>
<?
}
//if user registred before i.e. $_COOKIE[email] has a (valid) value
else
{
?>
<div id="navigation">
<ul>
<li><a href="index.php" class="active">Register</a></li>
<!-- should only make the links below a live link when a user is a registrered user-->
<li><a href="products.php">Products</a></li>
<li><a href="my_cart.php">My Shopping Cart</a></li>
</ul>
</div>
<br>
<div id="content">
<table>
<tr>
<td>
<br>
<br>
<p>Welcome, <? echo $_COOKIE['name']."! Thank you for registering under ".$_COOKIE['email'];?> email address.
<br>
<br>
Feel free to browse our Products and My Cart sections of the site.
<br>
<br>
<br>
<br>
<br>
<br>
Not <? echo $_COOKIE['name']; ?> registered under <? echo $_COOKIE['email']; ?>? Click <strong><a href="index.php?delete_cookie=1">here</a></strong>
</p>
</td>
</tr>
</TABLE>
</div>
<?
}
?>
<br>
<?
//include the header template
include("footer.html");
//flush the output buffer AFTER all the header() functions may have been used and thus avoid errors
//assoc. with outputting before hearder() functions
ob_end_flush();
?>

Re: problem running php on apache (xampp) after new install

PostPosted: 31. May 2010 08:29
by Altrea
keyword:
short_open_tags

Re: problem running php on apache (xampp) after new install

PostPosted: 31. May 2010 08:42
by Nobbie
Duke555 wrote:<php?


This runs neither on Windows nor on Linux, it's simply wrong.

Re: problem running php on apache (xampp) after new install

PostPosted: 03. June 2010 08:53
by Duke555
yes, thank you
it was wrong i was tryingt o get it to work by changing things and init. made a mistake in that scipt.
regardsless the post above is absolutely correct, i just had to make that change in the config. file.