...

View Full Version : Excuting a php from another...



tonyjms2005
09-20-2009, 12:50 PM
Hello

I would like to execute a php from another file, for example here is my index.php file:

<?php


// Obtain The GMT Time
$timestamp = gmdate("U");

// Build Datetime Strings
$Expires = sprintf("%s %02d %s %04d %02d:%02d:%02d GMT",
gmdate("D", $timestamp), gmdate("d", $timestamp),
gmdate("M", $timestamp), gmdate("Y", $timestamp),
gmdate("H", $timestamp), gmdate("i", $timestamp),
gmdate("s", $timestamp));

$LastModified = sprintf("%s %02d %s %04d %02d:%02d:%02d GMT",
gmdate("D"), gmdate("d"), gmdate("M"), gmdate("Y"),
gmdate("H"), gmdate("i"), gmdate("s"));

// Send Headers That Should Foil Proxy Servers
header("Expires: $Expires");
header("Last-modified: $LastModified");
header("Cache-Control: no-cache");

define("DATABASE_HOST", "********"); // localhost will usually suffice
define("DATABASE_USER", "*****"); //Your DB Info
define("DATABASE_PASSWORD", "******"); //Your DB Info
define("DATABASE_NAME", "*****"); //Your DB Info

//Establish Persistent Connection
$DatabaseLink = MySQL_pconnect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD) or die (MySQL_error());

//Select DB
MySQL_select_db(DATABASE_NAME) or die(MySQL_error());
$nume = $_POST['nume'];
?>
<?

$nume = htmlentities($nume);
if($nume != "")
{
$Query3 = "SELECT ID FROM candle WHERE Name=\"$nume\"";
$DatabaseResult3 = MySQL_query($Query3, $DatabaseLink);
if(!($DatabaseRow = MySQL_num_rows($DatabaseResult3)))
{

mysql_query("INSERT INTO candle(Name) VALUES(\"$nume\") ") or die(mysql_error());
}
}

?>
<?
$Query = "SELECT max(ID) AS Count FROM candle";
$DatabaseResult = MySQL_query($Query, $DatabaseLink);
$DatabaseRow = MySQL_fetch_object($DatabaseResult);
if ($DatabaseRow->Count>0) ?>

<html>
<body bgcolor="#FFFFFF" class="text" text="#575289" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<left><table border="0" cellpadding="0" cellspacing="0">

<table border=0" cellpadding="0" cellspacing="0">
<tr><td>
<p align="left"><font face="Arial">
</td></tr></table><p>

</td>
</tr></table>


<?
print($TotalCount);
if(!isset($preCount))
{
$preCount = $TotalCount - 10000;
}
if(!isset($Count))
{
$Count = $TotalCount + 10000;
}

?>

<?
if($submit == "Search" || $yes == "yes")
{
print("");
print("Search Result: ");
$Query = "SELECT ID, Name FROM candle WHERE Name LIKE \"%$search%\" ORDER BY ID DESC";
$DatabaseResult = MySQL_query($Query, $DatabaseLink);
while($DatabaseRow = MySQL_fetch_object($DatabaseResult))
{
$id = $DatabaseRow->ID + 5;
print("<a href=\"index.php?Count=$id\">$DatabaseRow->Name</a>");
}

if(MySQL_num_rows($DatabaseResult) == 0)
{
print("None found.");
print("<a href=\"index.php?Count=$TotalCount\"></a>");
}
}else
{

?>
<table cellspacing="30"><tr align="left">
<?

if($Count > 10000)
{
$preCount = $Count - 10000;
}
$interval = 0;
//$Query = "SELECT ID, Name FROM candle ORDER BY ID ASC";

$Query = "SELECT ID, Name FROM candle WHERE ID > \"$preCount\" AND ID < \"$Count\" ORDER BY ID DESC";
$DatabaseResult = MySQL_query($Query, $DatabaseLink);
while($DatabaseRow = MySQL_fetch_object($DatabaseResult))
{
$nume = $DatabaseRow->Name;
print("<td><img src=\"images/candles.gif\" width=\"35\" height=\"65\"><br>$nume</td>");
$interval++;
if($interval == 1)
{
print("</tr><tr>");
$interval = 0;
}
}
?>

<!--
ver=parseInt(navigator.appVersion)
ie4=(ver>3 && navigator.appName!="Netscape")?1:0
ns4=(ver>3 && navigator.appName=="Netscape")?1:0
ns3=(ver==3 && navigator.appName=="Netscape")?1:0

//-->
</script>


<?
}


?>
</td>
</tr>
</table>
</center>
</div>

<script LANGUAGE="JavaScript">
</script>


</body>
</html>

The bold bit is the code that I believe I from the form that excutes this file.
Basically I want to excute an exact copy of this file (index1.php) on the form submit.
The code of the form is not included with this file and if the form code is changed then it stops functioning.

What would I have to add the index.php to get it to execute the index1.php on form submit.

PS i dont know much about coding :(

Thanks

Antony

MattF
09-20-2009, 01:03 PM
Use require or include to incorporate external files.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum