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();
?>

    there are several possible causes

    the problem is that PHP is not running on the server (your PC with xampp)
    ..you should not be able to see the php code in the browser

    some contenders are:
    you do not have apache started : have you started it from the Xampp control module?
    - if you have it set to run as a service then check to see if anything is disabling it at startup

    or maybe the install is faulty

    then again maybe you dont have the script in the htdocs directory?

    and the php tags should be :
    <?php
    not
    <?

    that wont run on a new install of Xampp - your friends box my be running an old version of php which allows <?

      Write a Reply...