PHP - 301 Redirect In Dinamic Web Pages
Can you help me with this ?
when i check my seo, i recive this message: Quote Permanent Redirect Not Found Search engines may think www.sportskevesti.co and sportskevesti.co are two different sites.You should set up a permanent redirect (technically called a "301 redirect") between these sites. Once you do that, you will get full search engine credit for your work on these sites. thanks Similar TutorialsI have this code which logs in a user to my site but it only directs them to the login success page. i need to direct users to 3 different pages depending on their access level eg levels 1,2,4 but i dont know how to do this, can any one help or point me in the right direction?? thanks //Form <form name="form1" method="post" action="checklogin.php"> <strong>Member Login </strong> Username: <input name="UsersID" type="text" id="UsersID" /> Password: <input name="U_Password" type="password" id="U_Password" /> <input type="submit" name="Submit" value="Login" /></form> <?php $host="localhost"; // Host name $username=""; // username $password=""; // password $db_name="test"; // Database name $tbl_name="members"; // Table name // Replace database connect functions depending on database you are using. mysql_connect("$host", "$username", "$password"); mysql_select_db("$db_name"); //submitting query // username and password sent from form //NEVER Remove the mysql_real_escape_string. Else there could be an Sql-Injection! $mUsersIDe=mysql_real_escape_string($_POST['UsersID']); $U_Password=mysql_real_escape_string($_POST['U_Password']); $sql="SELECT * FROM $Users WHERE UsersID='$UsersID' and U_Password='$U_Password'"; $result=mysql_query($sql); //checking results // Replace counting function based on database you are using. $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row //Direct Userbased on result if($count==1){ // Register $UsersID, $U_Password and redirect to file "login_success.php" session_register("UsersID"); session_register("U_Password"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } Hello, I've just started using PHP in last few weeks. I did so because I wanted to create a Testing Interface for the Xubuntu Developement Channels on irc.freenode.net, this was my idea and I'm the solely responsable for it. If I can make it work like its sopose to they might consider using it. The Interface works, it stores daily tests from users and recovers it in a rather simple way. But now I need/want to create a way for the Team Leader to add scheluded tests for particular days, so I'm bassically adding a: Code: [Select] <?php $etad = date('Fd'); include './sch/$etad.htm'; ?> into one of my page table entries. And then what I'm doing is to create a FORM that aks for a Month and a Day, and then 16 selects named Sch[1-16], an All CheckBox, and an Announcements text area. What I want to do whit it is to send the form to a php script that will take all that info and create a Quote MonthDate.htm file into the ./sch folder. I started simple to see if stuff worked and so far i have: Code: [Select] <?php $MONTH = $_POST['MONTH']; $DAY = $_POST['DAY']; if (!$MONTH) { include "../fail.htm";} elseif (!DAY) { include "../fail.htm";} else { $filename = "$MONTH$DAY.htm";} $SCH1 = $_POST['SCH1']; $SCH2 = $_POST['SCH2']; $SCH3 = $_POST['SCH3']; $SCH4 = $_POST['SCH4']; $SCH5 = $_POST['SCH5']; $SCH6 = $_POST['SCH6']; $SCH7 = $_POST['SCH7']; $SCH8 = $_POST['SCH8']; $SCH9 = $_POST['SCH9']; $SCH10 = $_POST['SCH10']; $SCH11 = $_POST['SCH11']; $SCH12 = $_POST['SCH12']; $SCH13 = $_POST['SCH13']; $SCH14 = $_POST['SCH14']; $SCH15 = $_POST['SCH15']; $SCH16 = $_POST['SCH16']; $ALL = $_POST['ALL']; $ANNOUN = $_POST['ANNOUN']; if ( $ALL ) { $Content = "<h3><font color='#1E90EE'>Every Single Test! DO THEM ALL!</font></h3> For Instructions on how to do this tests please go to:<br /> <a href='http://testcases.qa.ubuntu.com/Install'>Ubuntu Tests Cases</a><br /> <br /> <p>$ANNOUN</p><br />"; } else { $Content = "nope"; } echo "open"; $handle = fopen($filename, 'x+'); echo " write"; fwrite($handle, $Content); echo " close"; fclose($handle); ?> This works, but now im facing all the SCH[1-16] variables, they are test cases names, each SCH can be up to 24 different options, each one related to a "how to test" web page. I could add Code: [Select] <?php if (!$SCH1) { $1HCS = NULL; } elseif ($SCH1 = "TestCase1") { $1HCS = "Test Case 1, <a href='link.to.test.com'>How to test</a>";} elseif (.... ?> and so on for the 24 test cases, and for the 16 selects! this is not very productive, and im sure there is a better way of doing it, but as I'm so new to this world I can't see another solution. So hereby I come to ask for guideness to you people. any help you can give will be greatly appreciated can help with the code to do this: I have a form with the following fields: form in detail: first part: NAME1, PHONE, ID, EMAIL second part: NAME2, EMAIL2 NAME3, EMAIL3 NAME4, EMAIL4 NAME5, EMAIL5 NAME6, EMAIL6 to first part i used "foreach" to send all data colect to mi email (in html) I want to send emails, the emails entered EMAILx fields, including the following phrase, "NAMEx, we recommend NAME1" in subject. to each of other name at your emails this is my code for the first part <? $mensaje = ""; foreach ($_POST as $llave=>$dato) { if ($llave != "Submit") $mensaje .= "$llave: $dato\n"; } //$to="sorteoancel@lafiestainolvidable.com.uy"; $to="sorteoancel@lafiestainolvidable.com.uy"; $subject="INSCRIPCION SORTEO ANCEL"; mail($to,$subject,$mensaje,"From: La Fiesta Inolvidable<No Replay>"); ?><title>La Fiesta Inolvidable</title> <style type="text/css"> <!-- body { background-color: #000000; background-image: url(); } .Estilo1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #CCCCCC; } .Estilo15 {font-size: 10px; color: #CCCCCC; } .Estilo16 {color: #FF0000} .Estilo17 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #CCCCCC; } .Estilo17 { font-size: 12px; color: #CCCCCC; font-weight: bold; } --> </style></head> <body> <meta name="keywords" content="nostalgia,sorteo,gratis"> </body> </html> Thz for any help I'm trying to put together a script that redirects visitors based on their IP, user agent and/or referral url. Basically I want the script to scan these three factors from the visitor, if any of them turn out to match my redirect-requirement it redirects the user. I know the code is horribly coded, I'm incredibly new to the php-scene and consider myself a complete noob. As you can see I want redirected visitors to go to google.com and un-redirected to msn.com(examples). Really thankful for all the help I can get! Right now nothing works, any suggestions? <?php function redirect($page) { Header( "HTTP/1.1 301 Moved Permanently" ); header('Location: ' . $page); exit; } $referrals=array('pitchingit.org','referral2'); $badAgents = array("useragent1", "useragent2"); $deny = array("78.105.191..*","100.101.103..*"); if (in_array($_SERVER['HTTP_REFERER'], $referrals, FALSE)) { header("Location: http://www.google.com"); } else { header("Location: http://www.msn.com"); } if(in_array($_SERVER['HTTP_USER_AGENT'],$badAgents)) { redirect("http://www.google.com/"); exit(); } $add=$_SERVER['REMOTE_ADDR']; foreach ($deny as $ip) { if (preg_match("^.$add.*^",$ip)) { redirect("http://www.google.com"); } } redirect("http://www.msn.com"); ?> How can one re-direct a visitor, without using a header re-direct? I'd like a page to show up, then after about 5 seconds I need the visitor sent to another page. How can I do this? like if I'm displaying a hundred entries , my website will be super long in length so I wanna break those hundred entries into maybe like 12 per page . Then click next page or the page number to view the next 12. Hi guys, this is my first post here. I'm looking for some help with some code for a form submission. It all works fine but if I add in a redirect using the advice found he http://www.computing.net/answers/webdevel/redirection-after-submit-php-form/3580.html. I'm using the following code: Code: [Select] <?php header ('Location: http://www.jwhunterhill.co.uk/return.html'); exit (); if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "xxx@gmail.com"; $email_subject = "E-mail from JWHunterHill.co.uk"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "^[a-z .'-]+$"; if(!eregi($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!eregi($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting me. I will be in touch with you very soon. <?php } ?> As I said the code works fine just if I include the redirect, the form will not send me an e-mail as required. Could you help me out please? Thanks in advance, Jonathon how do i redirect page within an if/else statement Hello everyone, I am new to php,and i am making my website......where i am unable to redirect a user to his respctive homepage.. Can anyone help me out with a sample script.......... Thanks, cool_techie Ok I know I can redirect using: header( 'Location: URL' ) ; Now, is there a way to delay this after a short while of displaying or would I have to use Javascript? Can someone tell me how to fix this At the top of every page i have this. Code: [Select] <?php include('GiveAway_Control.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" lang="en" xml:lang="en"> <head> in the GiveAway_Control.php there is the Code: [Select] header("Location: http://www.domain.com/winner.html"); /* Redirect browser */ The GiveAway_Control.php has NO echo statements what so ever. maybe a silly question, but when somebody visits my site i.e. domain.com i want it to redirect them to www.domain.com example can be seen @ facebook.com what the syntax to get out from the actual folder and redirect to some file outside ?? <?php header("Location: ???file.php"); exit; ?> I having trouble with my re-direct code on my php registration form. The form does submit data to the database but I'm getting the following error. "Warning: Cannot modify header information - headers already sent by (output started at /homepages/25/d232402382/htdocs/testencourage/registration.php:15) in /homepages/25/d232402382/htdocs/testencourage/registration.php on line 87" I would like the form goes to the thanks.php after submitting the data but its not doing its job. Here is the code. Code: [Select] <?php if ($_SERVER['HTTPS']) { header('location: https://www.fakewebsite.com'); } the regular html syntax <title>, site navigation, etc... ?> <?php if (isset($_POST['submitted'])){ $fields = array( 'email', 'state', 'district', 'gender', 'age', 'profession', ); if (safe($_POST['survey']=="Yes")){ $survey = "Yes"; } else{ $survey = "No"; } foreach($fields as $fieldName) { if(isset($_POST[$fieldName]) and safe(trim(stripslashes($_POST[$fieldName]))) !==''){ $$fieldName = safe(trim(stripslashes($_POST[$fieldName]))); }else { $errors[] = "Please enter your". $fieldName .""; //code to validate fields } } if(!isset($errors)){ require_once('Connections/encourage.php'); $query = "INSERT INTO participants (email, state, district, gender, age, profession, survey, registration_date) VALUES ('$email', '$state', '$district', '$gender', '$age', '$profession','$survey', NOW())"; //databasse connection $result = mysql_query ($query); if ($result){ $url = 'http://'. $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if ((substr($url, -1) == '/') || (substr($url, -1) == '\\')) { $url = substr ($url, 0 -1); } $url .= '/thanks.php'; header("Location: $url");// this is line 87 exit(); }else{ echo '<h1 id="mainhead">System Error</hl> <p>Your registration could not be completed due to a system error We apologize for any incovience</p>';//gives system error echo 'p' . mysql_error(). '<br /><br />Query: ' . $query . '</p>'; exit(); } mysql_close(); } else { echo '<h1 id="mainhead">Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach($errors as $msg) { echo " - $msg<br/>\n"; } echo '</p><p>Please try again.</p><p><br/></p>'; } } function safe($string) { $pattern = "/\r|\n|\%0a|\%0d|Content\-Type:|bcc:|to:|cc:/i"; return preg_replace($pattern, '', $string); } ?> Also I'm going to set up my ssl on the server so I'm planning to use that https redirect syntax but since I'm very new at this, am I missing something. Your help will be greatly appreciated, thanks! Hi all, I have a page url that looks like this: jobs.php?view=view&id=5 Their is a login on this page, the form ends with this command: header("Location: ".$session->referrer); The fuction for this is: <?php function startSession(){ global $database; //The database connection session_start(); //Tell PHP to start the session /* Determine if user is logged in */ $this->logged_in = $this->checkLogin(); /** * Set guest value to users not logged in, and update * active guests table accordingly. */ if(!$this->logged_in){ $this->username = $_SESSION['username'] = GUEST_NAME; $this->userlevel = GUEST_LEVEL; $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time); } /* Update users last active timestamp */ else{ $database->addActiveUser($this->username, $this->time); } /* Remove inactive visitors from database */ $database->removeInactiveUsers(); $database->removeInactiveGuests(); /* Set referrer page */ if(isset($_SESSION['url'])){ $this->referrer = $_SESSION['url']; }else{ $this->referrer = "/"; } /* Set current url */ $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; } ?> Basically $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; seems to cut my url to: jobs.php instead of: jobs.php?view=view&id=5 Can anyone here tell me how to fix this? Thanks Guys Im setting up members on my site i want the profile url to be like www.mywebsite.com/NATHAN but not go to a folder on my server called nathan but instead go to mywebsite.com/?profile=Nathan
Hi,
Can someone tell me what this redirect will do?
RewriteCond %{HTTP_HOST} ^(www\.)?website\.com/microsite$Thanks! <?php $get = fetch("SELECT number FROM dom") if "$get = 1" echo "<meta http-equiv='refresh' content='0;url=http://toxicpets.co.uk/down_for_maitenence.php'>"; elseif "$get = 0" echo "<meta http-equiv='refresh' content='0;url=http://toxicpets.co.uk/index.php'>"; ?> is this code right??? if you go to this page here http://www.nikita-andrews.com/ingrid/?page_id=34 you see it is a three column grid layout if you click on image and go to single post you will see above the post it will either say HOME/PORTFOLIO/CURRENT PAGE or HOME/(CATEGORY)/CURRENT PAGE if you click on Portfolio or Category (whichever category it may be) it takes you back to a vertical list of all the post in the category like such http://www.nikita-andrews.com/ingrid/?cat=5 ... is there a way to redirect that link to go back to the 3 grid layout portfolio or portfolio category page? Using wordpress ... not sure where the php would be located. Im guessing in single.php but not sure where the code for that function is located in there |