PHP - Auto Redirect To A Https Page
Hey Guys,
I have a question here and I'm strugling with it, what I am trying to do is redirecting the user as soon as he opens the page to a HTTPS pagefor example. I have a really long URL for my email loginpage so instead of giving user long loink with port number and stuff I have this address "http://company.com/mail" and actualy under this mail directir there is a index.php with this code Code: [Select] <?php header('Location: https://ssl.company.com/crm/webmail/this/location'); exit; exit(); ?> it works great but the problem is it send the user to the NONE-Secure page (HTTP) instead of the secure... Does anyone know how can I go around this?! Thanks Similar TutorialsThis is probably some silly mistake but I can't figure out why this code isn't working. I put this at the top of my php page: Code: [Select] <?php $https_url = 'https://somesite.com'; if ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'off' ) { header('location: ' . $https_url); exit; } else if ( !isset( $_SERVER['HTTPS']) && $_SERVER['SERVER_PORT'] == 443 ) { header('location: ' . $https_url); exit; } ?> When I was just trying this code out it worked and redirected to https. No errors no infinite loops...it worked perfectly. However, once our server guy actually applied the SSL to the page, the code stopped working and I get the error "The page must be viewed over a secure location." It throws the error before it processes anything on that page. I found the code online on another help forum and it worked for everyone else, so what am I doing wrong? I also tried a different version of the code that also works for everyone else but got the same error. Thanks for your help! Hi guys, We have an independent billing system that we use to track payments. I want to write a PHP script to automatically post a payment to the billing system. I went into the billing system, hit "View source" and got the link + required variables that will allow me to simulate entering a payment. The problem is that it's asking me to enter my credentials everytime I try to simulate the payment. Is a module or something that will automatically enter my credentials in this HTTPS site? Thanks Okay, my organanization has a page that we really need to autodirect to https:// in case anyone manually types in the http:// version. I've tried this (among many others) and it just sits there like a knot on a log: Code: [Select] <?php header( "Location: https://www.mywebsite.com/myfile.php" ) ; ?> Any ideas? It just simply doesn't redirect. It just sits there in its http:// format. I've also tried numerous other methods. None of them worked, either, but this is the simplest. Thanks! This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359577.0 I want to make sure that a specific page (login.php) only has stuff from my https and none from my (or other) http sites. How can I do this? Hi friends. I have a problem with https about $_SESSION in php last time my website is working correctly with http but after change to https I can send value of session to another page
login.php session_start(); $_SESSION['user_ID'] = 8;
Action.php session_start(); echo "User ID = " . $_SESSION['user_ID'] ; //// It's not show any thing
Thank you very much for your help Hi, I have a, let's call it, Main page, and it refreshes every 5 seconds to check the database... If it finds a result, it kills the refresh function and allows a DIV to call a page into itself via another function on the Main page, which refreshes every second, it's a timer count down clock... The problem is, that if the timer runs down to zero, I have it do a lot of things, but then I need it to either refresh the Main page, redirect the Main page, or close the Main page entirely... Does anyone know how I could perform either 3 of those actions from within the page that's inside of the DIV? Hi,
I am trying to redirect a page to another page based on if the page contains an image with an exact source.
I have this so far:
if ( $("span#bannerhold:has(img[src='http://www.website.com/images/banners/banner1.gif'])")){ location.href = "http://www.google.com" }However it doesn't seem to work. Any ideas why? Thanks! Hai Folks,
Please help me in this situation,
Actually my case is bit complicated
i have a list of few movies.please check the attached file.
If we click on each movies ,i want to direct into next page describing details of that clicked movie (review,image,syopsis,time).can you help me to write code
following is the code for showing movie list.
<?php Hello, Please... could someone look at my existing code below at tell me how I can establish a REDIRECT PAGE {header("Location: thankyou.php");} to fit in my code and WITHOUT generating a MySQL error once the php page is processed on the server? I wish to place the HTML CODE at bottom of my page labeled " // THE RESULTS OF THE FORM RENDERED AS PURE HTML " to be on a separate " thanks.php " page. thanks mrjap1 Code: [Select] <?php $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $registration_date = $_POST['registration_date']; // 1. Create a database connection $con = mysql_connect("localhost","mrino_mydata","runns100"); if (!$con) { die('Database connection failed could not connect: ' . mysql_error()); } // 2. Select a database to use $db_select = mysql_select_db("mrino_FULLENTRYDATA",$con); if (!$db_select) { die('Database selection failed could not connect: ' . mysql_error()); } mysql_select_db("mrino_FULLENTRYDATA", $con); // Data Submitted With My Form $sql="INSERT IGNORE INTO `mrino_FULLENTRYDATA`.`backpage1` (`id` , `first_name` , `last_name` , `email` , `registration_date`) VALUES (NULL , '$_POST[first_name]' , '$_POST[last_name]' , '$_POST[email]', NOW( ))"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } // 3. Close Connection mysql_close($con); ?> <?php // ALL THE SUBJECT and EMAIL VARIABLES $emailSubject = 'MY TEST EMAIL SCRIPTING!!! '; $webMaster = 'myemailaddress@gmail.com'; // GATHERING the FORM DATA VARIABLES $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $registration_date = $_POST['registration_date']; $date = date ("l, F jS, Y"); $time = date ("h:i A"); $body = <<<EOD <br /><hr><br /> <strong>First Name:</strong> $first_name <br /> <strong>Last Name: </strong>$last_name <br /> <strong>Email:</strong> $email <br /> <strong>Registration Date:</strong> $date at $time <br /> EOD; // THIS SHOW ALL E-MAILED DATA, ONCE IN THE E-MAILBOX AS READABLE HTML // Remove Header Injections $match = "/(bcc:|cc:|content\-type:)/i"; if (preg_match($match, $from) || preg_match($match, $subject) || preg_match($match, $body)) { die("Header injection detected."); } // Simple filtering on all of our input variables $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); $from = preg_replace("([\r\n])", "", $_POST['email']); $emailSubject = preg_replace("([\r\n])", "", $_POST['$emailSubject']); // THE RESULTS OF THE FORM RENDERED AS PURE HTML $theResults = <<<EOD <!DOCTYPE HTML> <html lang="en"> <head> <style type="text/css"> body { font-family:Arial, Helvetica, sans-serif; font-size:11px; font-weight:bold; } #thankyou_block { width: 400px; height: 250px; text-align:center; border: 1px solid #666; padding: 5px; background-color: #0CF; border-radius:8px; -webkit-border-radius:8px; -moz-border-radius:8px; -opera-border-radius:8px; -khtml-border-radius:8px; box-shadow:0px 0px 10px #000; -webkit-box-shadow: 0px 0px 10px #000; -moz-box-shadow: 0px 0px 10px #000; -o-box-shadow: 0px 0px 10px #000; margin: 25px auto; } p { font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px; letter-spacing:1px; color: #333; } </style> <meta charset="UTF-8"> <title>THANK YOU!!!</title> </head> <body> <div id="thankyou_block"> <br><br><br> <h1>CONGRATULATIONS!!</h1> <h2>YOUR FORM HAS BEEN PROCESSED!!!</h2> <p>You are now registered in our Database...<br> we will get back to you very shortly.<br> Please have a very wondeful day.</p> </div> </body> </html> EOD; echo "$theResults"; ?> hello, so i have this contact page on my website, but i want people to actually know if the mail got sent or not, so i first have contact.php, which sends all the information to sendmail.php, which in turn tells redirect.php wether or not the mail was sent, and redirect.php then shows this information for the user to see, and has a 10 second timer before users get sent back.. here is the website: http://hcg.drokz.eu.clanservers.com/ all files are in the same folder so here is my code: Code: (sendmail.php) [Select] <?php $url1 = 'redirect.php?sent=sent'; $url2 = 'redirect.php?sent=fail'; $timeout = 0; ?> <?php $to = "admin@hcg.drokz.eu.clanservers.com"; $name = $_REQUEST['name'] ; $subjectm = $_REQUEST['subject'] ; $subject = "contact form entry on the hcg website by $name with the subject $subjectm"; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; ?> <?php if($sent) {header('Refresh: ' . $timeout . ';url=' . $url1); ?> <meta http-equiv="refresh" content="<?php echo($timeout) ?>;url=<?php echo($url1); ?>"> <script type="text/javascript"> setTimeout(function(){window.location.replace("<?php echo($url1); ?>";}, <?php echo($timeout * 1000); ?>); </script> <?php } ; ?> <?php else {header('Refresh: ' . $timeout . ';url=' . $url2); ?> <meta http-equiv="refresh" content="<?php echo($timeout) ?>;url=<?php echo($url2); ?>"> <script type="text/javascript"> setTimeout(function(){window.location.replace("<?php echo($url2); ?>";}, <?php echo($timeout * 1000); ?>); </script> <?php } ; ?> <a href='contact.php'> this page should redirect you, if nothing happens, click here! </a> Code: (redirect.php) [Select] <?php $sent = $_GET['sent'] ; ?> <?php $url = 'contact.php'; $timeout = 10; ?> <?php header('Refresh: ' . $timeout . ';url=' . $url); ?> <meta http-equiv="refresh" content="<?php echo($timeout) ?>;url=<?php echo($url); ?>"> <script type="text/javascript"> setTimeout(function(){window.location.replace("<?php echo($url); ?>";}, <?php echo($timeout * 1000); ?>); </script> <h1> <?php if($sent == sent) {echo "Success!" } ; elseif($sent == fail) {echo "Failure!" } ; ?></h1> <?php if($sent == sent) {echo "your email has been sent successfully and we will reply as soon as we can."} ; elseif($sent == fail) {echo "we have encountered a problem while sending your email, please try again!"} ; ?> <p> <a href='contact.php'> this page will redirect you in 10 seconds, if nothing happens or you can't wait, click here! </a> Hello everyone, I am creating a site that has two modes 1.Default 2.under construction I use database to see weather the site is under construction or not. The template of under construction is different and is stored in a another directory eg: site url: www.my.com under construction page: www.my.com/uc now i want that when the database is selected for under construction the URL should show www.my.com not www.my.com/uc Please help me with this. I tried to redirect with header(location: '.......'); but in the URL it shows www.my.com/uc Thanks. Hi all, I am using php to allow users to create a new directory e.g. www.website.com/theirname/ and would like to auto generate an index.php (or index.html) page if possible within this directory. Any tips on how to do it would be appreciated. The code I have for generating the directory is: <?php function handleError() { trigger_error('MY ERROR'); /** usage sample @handleError(); echo $php_errormsg; */ } // detect slash/backslash nomenclature dirname $path = dirname( __FILE__ ); $slash = '/'; (stristr( $path, $slash )) ? '' : $slash = '\\'; define( 'BASE_DIR', $path . $slash ); $folder = $_POST['reg']; // folder name $dirPath = BASE_DIR . $folder; // folder path // print results echo $slash; echo '<hr>'; $rs = @mkdir( $dirPath, 0777 ); @handleError(); if( $rs ) { // print success information echo 'was done!'; echo '<br>folder: <a href="' . $folder . '">' . $folder . '</a>'; echo '<br>dirPath: ' . $dirPath; }else{ // print error information echo "This webpage <b>www.website.com/".$folder."</b> appears to have been already been created. Please try another web name. If the problem persists please report it to us."; } ?> Hi,
Am working on hooks wit codeigniter, am getting an error after applying hooks like "This webpage has a redirect loop".
My hooks.php file :
$hook['post_controller_constructor'] = array(
'class' => 'SessionData',
'function' => 'initializeData',
'filename' => 'auth.php',
'filepath' => 'hooks',
'params' => array()
);
auth.php file:
<?php
class SessionData{
var $CI;
function __construct(){
$this->CI =& get_instance();
if(!isset($this->CI->session))
$this->CI->load->library('session');
}
function initializeData() {
if(!$this->CI->session->userdata('admin_id')){
redirect('admin');
}
}
}
?>
Admin controller file:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
After I input a number and press submit, it'll do some calculating and write the number to a file. Once its done I want it to go to another page but it doesn't seem to work. Ive tried header with no luck .
Heres my code: $number = $_POST['number-entered']; foreach ( range(1, $number) as $i ) { $triangle_numbers[] = $i * ( $i + 1 ) / 2; } //make a file $contents = fopen('gs://a1-task22020.appspot.com/triangular_' .$number. ".txt", "w"); fwrite($contents,implode(',', $triangle_numbers)); //open the file $contents = fopen('gs://a1-task22020.appspot.com/' . $content, 'w'); //re-open the document if you put something in it fwrite($contents, $number); fclose($contents); } header("Location: https://a1-task22020.ts.r.appspot.com/result.php"); } ?>
Hi, I have set up a new website, but the old website is using /mainpage.html as it's homepage when searching in Google. This page no longer exists, so when a user clicks on the page in Google, the website is not found. Is there a way i can set up a forwarder to point the missing file to the new index.php page? Thanks hello, I have created a website which has to incorporate administration features. I hjave been trying to do this for a couple of days and any help will be much appreciated. I have a login screen (form) when the user enters their username and password they are brought to the homepage.php. Is there anyway to redirect the administrator (username=admin) to a different page from all ordinary members? e.g. deletemember.php Thanks I am a newbie to php.. Used to do work in Cold Fusion and I cannot figure out what I am doing with a registration page I have created. I am looking to have the page insert into two databases, which it is doing, and then redirect to the main member's page. I have been looking for something and have not found anything here or online that works for me. I understand that you cannot use header() after any type of html or echo, but I have tried .js and other methods. I am not throwing errors, just no redirect... Also I am interested in hearing how bad my code is... any positive criticism is appreciated, as I am still learning Here is my code: Code: [Select] <?php include("dbc.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Registration Page</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="style.css" type="text/css" charset="utf-8"> <link rel="stylesheet" href="styles.css" type="text/css" charset="utf-8"> //Some Javascript... </script> </head> <body> //Some Styling... <!-- content goes here --> <h1>Register</h1> <?php ob_start(); error_reporting(0); $_POST = array_map('secure', $_POST); if($_POST['submit']) { $user_name = mysql_real_escape_string($_POST['user_name']); $query = mysql_query("SELECT * FROM xxxxusers WHERE user_name='$user_name'"); $query = mysql_query("SELECT * FROM xxxusers WHERE user_name='$user_name'"); if(mysql_num_rows($query) != 0) { echo "<div style="font-size: 9pt; font-weight: bold;color: red;">Username already exists</div>"; } else { $user_password = mysql_real_escape_string($_POST['user_password']); $user_pass = mysql_real_escape_string($_POST['user_pass']); $user_email = $_POST['user_email']; $query = mysql_query("SELECT * FROM xxxxusers WHERE user_email='$user_email'"); $query = mysql_query("SELECT * FROM xxxusers WHERE user_email='$user_email'"); if(mysql_num_rows($query) != 0) { echo "<div style="font-size: 9pt; font-weight: bold;color: red;">Email already exists</div>"; } else { $enc_password = md5($user_password); $enc_password = md5($user_pass); if($user_name && $user_password && $user_pass && $user_email) { if (strlen($user_name)>20) { echo "<div style="font-size: 9pt; font-weight: bold;color: red;">Your Name is Too Long</div>"; } $email = htmlspecialchars($_POST['user_email']); if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { echo "<div style="font-size: 9pt; font-weight: bold;color: red;">E-mail address not valid</div>"; } { require "dbc.php"; mysql_query("INSERT INTO xxxxusers stuff....) VALUES(stuff....) ") or die(mysql_error()); mysql_query("INSERT INTO xxxusers stuff....) VALUES(stuff....) ") or die(mysql_error()); } } else echo "<div style="font-size: 9pt; font-weight: bold;color: red;">All Fields Are Required</div>"; } } } ob_end_flush(); ?> <form action="register.php" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr> <td>Username:</td> <td><input type="text" name="user_name" maxlength="30" value="<?php echo "$user_name"; ?>"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="user_password" maxlength="30" value=""></td> </tr> <tr> <td>Confirm password:</td> <td><input type="password" name="user_pass" maxlength="30" value=""></td> </tr> <tr> <td>Email address:</td> <td><input type="text" name="user_email" maxlength="50" value=""<?php echo "$user_email"; ?>""></td </tr> <tr><td colspan="2" align="right"> <input type="submit" value="Register!" id="submit" name="submit"></td></tr> <tr><td colspan="2" align="left"><a href="index.php">Back to Home Page</a></td></tr> </table> </form> Afternoon All. I wish to re-direct users to a 404 error page on my site if an article does not exist in my database. Here's my code: $SQL = "SELECT headline FROM news WHERE news_id=".mysql_real_escape_string($_GET['news_id']); $result = mysql_query($SQL) OR die(mysql_error()); $num = mysql_num_rows($result); //** Check that the entry exists otherwise send to error page if ($num > 0) { $row = mysql_fetch_array($result); $headline = $row['headline']; } else { echo "Why is this printed? - I should be leaving this page?"; header("Location: error.php"); exit; } Now the wierd thing is that when I enter a news_id for a value that does not exist it prints the message Why is this printed? - I should be leaving this page? so it's actually going to the ELSE statement which is good, but surely it should not do this as I ask the page to re-direct? Thank you hi we want some code can any one help me what i do? we have traffic on site1.com we want this traffic redirect to another site site2.com i know how to redirected .but when echo $_SERVER["HTTP_REFERER"] in site2.com its show me traffic from google.com not show traffic from site1.com how to code please help me |