Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using PHP to link to another website.

Status
Not open for further replies.

Programz8

Programmer
Mar 27, 2007
33
0
0
US
Greetings,

I'm working on a website and I need one link to lead to another website within the existing browser with my banner and side link bar. Here is an example of the code.
<?php
// Start an if.......else block that checks for a a value for id
if (!$a_id) {
session_start();

}

// Start an if..else check value of $valid then action based on result
if ($valid != "yes") {

// send user back to login form and exit script
session_register('valid');
}

// create variable to hold name of db that the table resides
$db_name = "db";

// create variable to hold name of table you are populating
$table_name = "table";

// add connection information
$connection = @mysql_connect("localhost", "db", "password")
or die (mysql_error());

$db = @mysql_select_db($db_name,$connection) or die(mysql_error());

// perform some validation on value of $id make sure number exists in system
$chk_id = "SELECT a_id FROM $table_name WHERE a_id = \"$a_id\"";

//Create variable to hold result of mysql_query() function. Include @ to surpress warnings
//as well as the die () function to cause the script to end and a messager displays if query fails
$chk_id_res = @mysql_query($chk_id,$connection) or die ("Couldnt execute query.");

//create variable to count the number of rows within the result there should b 1
$chk_id_num = mysql_num_rows($chk_id_res);

// start and ifelse to deal with results, check row count correct answer is 1
if ($chk_id_num == "0") {

// if row count is zero the id is invalid redirect and exit script
header("Location: exit;
// Continue ifelse acting on valid result
} else {

// Create the sql statement select all fields of db except id for the record that has
// same ID value
$sql ="SELECT article_name, image, text, bigimage, alttext FROM $table_name WHERE a_id = \"$a_id\"";
}

// Create a variable to hold result of sql query function. Include at sign
// to supress warnings, as well as the die() function error message if query fails
$result = @mysql_query($sql,$connection) or die ("aint gonna be able to do it");

// Start while loop to create array for $row variable for each record in result set
while ($row = mysql_fetch_array($result)) {

// Get individual elements of the record and give them good names.
$article_name = $row[article_name];
$image = $row[image];
$text = $row[text];
$bigimage = $row[bigimage];
$alttext = $row[alttext];

}

?>

and I'm also providing a link to an example of what I want. Only difference instead of the anna nicole article can I embed another website such as google? while I still have my banner and side bar displayed on the page?
 
take a look at file_get_contents() and the allow_url_fopen directive in php.ini.

 
Unfotunately I am using a web host and I don't have access to the php.ini file :(
 
and have you determined whether allow_url_fopen turned on or off with your webhost? a call to phpinfo() will give you the answer.
 
allow_url_fopen Off On


The local value is off while the master value is ON

thanks,

Programz8
 
that's interesting.
try uploading a file called php.ini with the following in it

Code:
allow_url_fopen ON

upload the file to the directory in which the script resides and rerun the phpinfo() test. there is an off chance that the host will allow manipulation of certain directives through this method (or the upload of an .htaccess file)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top