Quote Originally Posted by Nightwalker83 View Post
With xhtml the php needs to be in the same file as the html in order to work:

Code:
<p align="center"><strong><font size="7" face="Courier New, Courier, monospace">Welcome to Bazaar Ceramics</font></strong></p>
<p align="center">Please select one of the options below: <br />
</p>
<table width="650" border="1" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td><div align="center"><strong><a href="getCustomerDetails.php">Customer Registration</a> </strong></div></td>
    <td><div align="center"><strong>Display Catalogue </strong></div></td>
    <td><div align="center"><strong>Account Order </strong></div></td>
    <td><div align="center"><strong>Shopping Cart </strong></div></td>
    <td><div align="center"><strong><a href="getProductDetails.php">Product Entry</a> </strong></div></td>
  </tr>
</table>
<hr>
<?php

/*check if form fields are blank. If they are, let the customer know and
provide a link to return to the original customer details form*/
if ($_POST["productname"] ==""){
echo "you need to enter the product name";
echo "<br><a href='getProductDetails.php'>Return to form</a>";

} elseif ($_POST["productdesc"] =="") {
echo "you need to enter the product description.";
echo "<br><a href='getProductDetails.php'>Return to form</a>";

}elseif($_POST["colour"] == ""){
echo "you need to enter a colour";
echo "<br><a href='getProductDetails.php'>Return to form</a>";

}elseif($_POST["price"] == ""){
echo "you need to enter a price";
echo "<br><a href='getProductDetails.php'>Return to form</a>";

}elseif($_POST["imagepath"] == ""){
echo "you need to enter a correct image path";
echo "<br><a href='getProductDetails.php'>Return to form</a>";

}else {

$conn = @mysql_connect("localhost", "root", "");
if (!$conn) {
die("Connection failed: " .mysql_error());
}

mysql_select_db("Bazaar Ceramics", $conn);

$query = "INSERT INTO products (productname, productdesc, colour, price, imagepath) 
VALUES ('$_POST[productname]', '$_POST[productdesc]', '$_POST[colour]', '$_POST[price]', '$_POST[imagepath]')";

if (mysql_query($query, $conn)){
	echo ("<br><b>The following product has been added to the database: </b>" .$_POST[productname]);
	echo "<br><br><a href=getProductDetails.php>Add another product?</a>";
}else {
	die(mysql_error());
}
}
?>
However, it is possible to link to the php page like so:

Code:
   <a href="getCustomerDetails.php">Customer Registration</a>
Really? You sure you want to stick to that statement? Because I've built sites with my PHP scattered across several files. Even still... unless the file is told to be processed as a PHP file, simply including the php script markers doesn't make it go.... What you'll get instead is the PHP code rendered to the client.


modpluz - I'm still unclear on why the files can't be renamed to PHP files?

-tg