NathanS Posted August 17, 2007 Share Posted August 17, 2007 Hi there, I want, after the below script has run, to redirect back to homepage - however I can't use the header function as i send html first. Any way of getting this page to redirect after the main script has run? Thanks a million! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="topcard.css" title="" /> <link rel="stylesheet" type="text/css" href="color-scheme.css" title="" /> <title>HIC Top Cards</title> </head> <body> <div id="top"></div> <div id="header"> <span class="headerTitle">HIC Top Cards</span> <div class="menuBar"> <a href="http://printsrv/">Main</a>| <a href="http://www.hic.com">HIC Intranet</a> </div> </div> <div class="sideBox LHS"> <div>Front End</div> <a href="#">› Submit Number</a> </div> <div class="sideBox LHS"> <div>Finance</div> <a href="#">› Run Report</a> </div> <div id="bodyText"> <?php //Let's determine the server variables and set 'em here. $myServer = "192.168.1.175"; $myUser = "sa"; $myPass = ""; $myDB = "Transactor_Version62"; $polno = $_POST['polno']; //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); //select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); //declare the SQL statement that will query the database $query = "SELECT * "; $query .= "FROM customer_policy_details "; $query .= "WHERE policynumber = '$polno'"; $query .= "AND live = 1"; //execute the SQL query and return records $result = mssql_query($query); $numRows = mssql_num_rows($result); while($row = mssql_fetch_array($result)) { $row1 = "$row[0]"; $row2 = "$row[1]"; $row3 = "$row[2]"; $row4 = "$row[3]"; $row5 = "$row[4]"; $row6 = "$row[5]"; } echo "Please wait, the server is dealing with your request . . . ."; //close the connection mssql_close($dbhandle); //and let's start the MySQL connection to write to ;] $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'hiccm23'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'topcards'; mysql_select_db($dbname); $sql = "INSERT INTO topcards (row1, row2, row3, row4, row5, row6) VALUES ('$row1', '$row2', '$row3', '$row4', '$row5', '$row6')"; mysql_query($sql) or die('Error, insert query failed - please contact IT Support '); ?> </div> <BR /> <BR /> <div id="footer"> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/65402-solved-help/ Share on other sites More sharing options...
m1a2x3x7 Posted August 17, 2007 Share Posted August 17, 2007 you can use the html redirect <meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com"> put this in your head. The content is how many seconds you want before you are sent to that page. Link to comment https://forums.phpfreaks.com/topic/65402-solved-help/#findComment-326567 Share on other sites More sharing options...
NArc0t1c Posted August 17, 2007 Share Posted August 17, 2007 Make a function that has the header function. Example: <?php function refresh($location){ header("Location: " . $location); } /* HTML goes here */ /* Page has phrased, call the function again. */ refresh("index.php"); ?> Link to comment https://forums.phpfreaks.com/topic/65402-solved-help/#findComment-326597 Share on other sites More sharing options...
NathanS Posted August 17, 2007 Author Share Posted August 17, 2007 Thanks guys! Link to comment https://forums.phpfreaks.com/topic/65402-solved-help/#findComment-326658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.