PHP - Redirect After Button Is Pushed Twice?
this is my code so far...
Code: [Select] <form action="<?php if ($_SESSION['reply_has_been_clicked'] != '1') { echo '';} elseif ($_SESSION['reply_has_been_clicked'] == '1') {echo 'thread_redirect.php';}?>" method='post'> <?php $_SESSION['current_thread'] = $the_thread_title . '.php'; if (($_SESSION['logged_in'] == '1') && (isset($_POST['reply_to_thread'])) && ($_SESSION['reply_has_been_clicked'] != '1')) { echo "<textarea name='thread_reply' style='resize:none;' cols='75' rows='10'>Enter your reply here...</textarea>"; echo "<br>"; $_SESSION['reply_has_been_clicked'] = '1'; } elseif (($_SESSION['logged_in'] != '1') && (isset($_POST['reply_to_thread']))) { $reply_echo = 'You need to be logged in!'; } ?> <input type='submit' name='reply_to_thread' value="Reply"> <?php echo $reply_echo; ?> so this works but it takes three button pushes to do the job. I can't think of anyother way to do it. help please! Similar TutorialsHere is code that i want to redirect after submitting to another url
<div class="js-ticket-form-btn-wrp"> I have two pages. one is insert_events.php and the other is veiw_events. In insert_events i have a form which have a submit button. I want when i click on the submit button, it redirects me to the view_events.php page showing the events. Any idea about this problem will be appreciated. Thanks This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=357107.0 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? Friends I am new to php and i have to submit my coursework in php by 3rd dec, I stuck at one place where i have to upload multiple photo and one can see all the photo he has uploaded and can edit or delete that photo so i have done uploading now i am showing those pics in table by running loop and generating tr and td but now i have two buttons with each row edit and delete now when i clicked on one delete or edit that pic should be delete or give text box to edit description of pic, Please help me how to do that....... If you look at this form: kmkwebdevelopment.com/formtest/upload.php you will see that when you click on the "add another upload box" button, instead of it adding another upload box, it is submitting the form for some reason. Can anyone see where the error lies? Relevant snippet of code below: <?php //deafult number of upload boxes $upload_quant = 4; //if the user increased the number of boxes if(isset($_POST['increase_upload'])) { //increasing the number of upload boxes $upload_quant = $_POST['previous_upload'] + 1; } $upload_quantity = $_POST['previous_upload']; //getting all the names into an array $uplaoded_array = array(); for($i=0;$i<$upload_quantity;++$i) { $ii = $i+1; $upload_name = 'upload'.$ii; $get_upload_name = $_POST['$upload_name']; array_push($uplaoded_array,$get_upload_name); } ?> <form class="uploadform" action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post" enctype="multipart/form-data" onSubmit="return CheckForm(this);"> <?php IsThereErrors("0", $_iserrors); ?> <input type="hidden" name="_referer" value="<?php echo $_referer ?>"> <input type="hidden" name="_next_page" value="1"> <p class="form_expert_style"><input name="URL" type="text" value=""/></p> <table> <tr> <td>First Name *</td> <td><input type='text' size='30' name='firstname' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("firstname", "") ?> value="<?php echo isset($_values["firstname"]) ? htmlspecialchars($_values["firstname"]) : "" ?>"></td> </tr> <tr> <td>Last Name *</td> <td><input type='text' size='30' name='lastname' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("lastname", "") ?> value="<?php echo isset($_values["lastname"]) ? htmlspecialchars($_values["lastname"]) : "" ?>"></td> </tr> <tr> <td>E-mail *</td> <td><input type='text' size='30' name='email' onblur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("email", "") ?> value="<?php echo isset($_values["email"]) ? htmlspecialchars($_values["email"]) : "" ?>"></td> </tr> <tr> <td>Company Number *</td> <td><input type='text' size='30' name='companynumber' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("companynumber", "") ?> value="<?php echo isset($_values["companynumber"]) ? htmlspecialchars($_values["companynumber"]) : "" ?>"></td> </tr> <?php for($i=0;$i<$upload_quant;++$i) { $ii = $i+1; $upload_name = 'upload'.$ii; echo <<<_END <tr> <td>Upload $ii</td> <td><input class="image" type='file' size='30' name='$upload_name'></td> </tr> _END; } echo <<<_END <tr> <td> <input type="hidden" value="$upload_quant" name = "previous_upload"/> <input type="submit" name="increase_upload" value="Add another upload box" /> </td> <tr> <td><input type="submit" name="SubmitBtn" onClick="CheckForm1();" value="SUBMIT" /></td> </tr> </table> </form> _END; } ?> </html> <?php Thanks I am editing this page (attached) and I'm trying to create another button to an external link. I thought it would be as easy as copying and pasting the text to create a second button but that kills the entire page. Any suggestions on how I might do this? This link is internally but the second button I need to open an external URL in a new window. The section of PHP: <div class="clear"></div> <?php // Ask a question about this product ?> <?php if (VmConfig::get('ask_question', 0) == 1) { $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE); ?> <div class="clear"></div> <div class="ask-a-question"> <a class="ask-a-question" href="<?php echo $askquestion_url ?>" rel="nofollow" ><i class="fas fa-envelope"></i><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a> </div> <?php } ?> <?php // Back To Category Button if ($this->product->virtuemart_category_id) { $catURL = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$this->product->virtuemart_category_id, FALSE); $categoryName = vmText::_($this->product->category_name) ; } else { $catURL = JRoute::_('index.php?option=com_virtuemart'); $categoryName = vmText::_('COM_VIRTUEMART_SHOP_HOME'); } ?>
<?php /** * * Show the product details page * * @package VirtueMart * @subpackage * @author Max Milbers, Eugen Stranz, Max Galt * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2014 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: default.php 9292 2016-09-19 08:07:15Z Milbo $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); /* Let's see if we found the product */ if (empty($this->product)) { echo vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); echo '<br /><br /> ' . $this->continue_link_html; return; } echo shopFunctionsF::renderVmSubLayout('askrecomjs',array('product'=>$this->product)); if(vRequest::getInt('print',false)){ ?> <body onload="javascript:print();"> <?php } ?> <div class="product-container productdetails-view productdetails"> <div class="vm-product-wrap row"> <div class="vm-product-media-img col-sm-5"> <?php echo $this->loadTemplate('images'); $count_images = count ($this->product->images); if ($count_images > 1) { echo $this->loadTemplate('images_additional'); } ?> </div> <!--/.col-sm-5--> <div class="vm-product-details-inner col-sm-7"> <div class="vm-product-title"> <div class="pull-left"> <?php // Product Title ?> <h2><?php echo $this->product->product_name ?></h2> <?php // Product Title END ?> </div> <div class="vm-rating pull-left"> <?php if (VmConfig::get('display_stock', 1)) { ?> <?php if ($this->product->product_in_stock > 0) { ?> <div class="product-in-stock"> <i class="pe pe-7s-check"></i> <?php echo JText::_('VM_IN_STOCK'); ?> <span><?php echo $this->product->product_in_stock; ?></span> </div> <?php } else { ?> <div class="product-in-stock"> <i class="pe pe-7s-less"></i> <?php echo JText::_('VM_OUT_OF_STOCK'); ?> </div> <?php } ?> <?php } ?> <?php echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>$this->showRating,'product'=>$this->product)); ?> </div> </div> <?php echo $this->product->event->afterDisplayTitle ?> <?php if (is_array($this->productDisplayShipments)) { echo '<div class="vm-product-shipments">'; foreach ($this->productDisplayShipments as $productDisplayShipment) { echo '<div class="vm-product-shipment">'; echo $productDisplayShipment . '<br />'; echo '</div>'; } echo '</div>'; } //In case you are not happy using everywhere the same price display fromat, just create your own layout //in override /html/fields and use as first parameter the name of your file echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$this->product,'currency'=>$this->currency)); echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'ontop')); echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'normal')); ?> <?php if (!empty($this->product->product_s_desc)) { ?> <div class="product-short-description"> <h4><i class="pe pe-7s-note"></i><?php echo JText::_('VM_PRODUCT_SHORT_DESC');?></h4> <?php // Removed line because it was generating <br>: echo nl2br($this->product->product_s_desc); echo $this->product->product_s_desc; ?> </div> <?php } // Product Short Description END ?> <?php // Manufacturer of the Product if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) { echo '<div class="clear"></div><span class="product-manufacturer">' . vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL') . ':' . $this->loadTemplate('manufacturer') . '</span><div class="clear"></div>'; } ?> <div class="spacer-buy-area"> <?php echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product)); echo shopFunctionsF::renderVmSubLayout('stockhandle',array('product'=>$this->product)); ?> </div> <div class="clear"></div> <?php // Ask a question about this product ?> <?php if (VmConfig::get('ask_question', 0) == 1) { $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE); ?> <div class="clear"></div> <div class="ask-a-question"> <a class="ask-a-question" href="<?php echo $askquestion_url ?>" rel="nofollow" ><i class="fas fa-envelope"></i><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a> </div> <?php } ?> <?php // Back To Category Button if ($this->product->virtuemart_category_id) { $catURL = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$this->product->virtuemart_category_id, FALSE); $categoryName = vmText::_($this->product->category_name) ; } else { $catURL = JRoute::_('index.php?option=com_virtuemart'); $categoryName = vmText::_('COM_VIRTUEMART_SHOP_HOME'); } ?> <div class="back-to-category"> <a href="<?php echo $catURL ?>" class="product-details"><i class="fas fa-folder-open"></i><?php echo vmText::sprintf('COM_VIRTUEMART_CATEGORY_BACK_TO',$categoryName) ?></a> </div> <?php // Product Navigation if (VmConfig::get('product_navigation', 1)) { ?> <hr style="width:100%;" /> <div class="product-neighbours"> <?php if (!empty($this->product->neighbours ['previous'][0])) { $prev_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['previous'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE); echo JHtml::_('link', $prev_link, $this->product->neighbours ['previous'][0] ['product_name'], array('rel'=>'prev', 'class' => 'previous-page', 'data-toggle' => 'tooltip', 'title' => $this->product->neighbours ['previous'][0] ['product_name'], 'data-dynamic-update' => '1')); } else { echo '<span class="empty-previous-page fas fa-ban"></span> '; } if (!empty($this->product->neighbours ['next'][0])) { $next_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['next'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE); echo JHtml::_('link', $next_link, $this->product->neighbours ['next'][0] ['product_name'], array('rel'=>'next','class' => 'next-page','data-toggle' => 'tooltip', 'title' => $this->product->neighbours ['next'][0] ['product_name'],'data-dynamic-update' => '1')); } else { echo '<span class="empty-next-page fas fa-ban"></span>'; } ?> </div> <?php } // Product Navigation END ?> <?php // Product Edit Link echo $this->edit_link; // Product Edit Link END ?> </div> <!--/.col-sm-7--> <div class="clear"></div> </div> <!--/.row--> <div style="margin-top:25px;" class="row"> <div class="col-sm-12"> <?php // PDF - Print - Email Icon if (VmConfig::get('show_emailfriend') || VmConfig::get('show_printicon') || VmConfig::get('pdf_icon')) { ?> <div class="icons"> <?php $link = 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->virtuemart_product_id; echo '<span class="pdf-icon">'; echo $this->linkIcon($link . '&format=pdf', 'COM_VIRTUEMART_PDF', 'pdf_button', 'pdf_icon', false); echo '</span>'; //echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon'); echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon',false,true,false,'class="printModal"'); $MailLink = 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component'; echo $this->linkIcon($MailLink, 'COM_VIRTUEMART_EMAIL', 'emailButton', 'show_emailfriend', false,true,false,'class="recommened-to-friend"'); ?> <div class="clear"></div> </div> <?php } // PDF - Print - Email Icon END ?> <?php // event onContentBeforeDisplay echo $this->product->event->beforeDisplayContent; ?> <div class="products-desc-tab"> <ul id="myTab" class="nav nav-tabs" role="tablist"> <?php if (!empty($this->product->product_desc)) { ?> <li role="presentation" class="active"> <a href="#desc" aria-controls="desc" role="tab" data-toggle="tab"> <i class="pe pe-7s-note"></i><?php echo vmText::_('VM_PRODUCT_DESC_TITLE') ?> </a> </li> <?php } // Product Description END if ($this->showReview) { ?> <li role="presentation"> <a href="#review" data-toggle="tab" aria-controls="review" role="tab"> <i class="pe pe-7s-like2"></i><?php echo JText::_('VM_PRODUCT_REVIEWS');?> </a> </li> <?php } ?> </ul> <div class="tab-content"> <?php if (!empty($this->product->product_desc)) { ?> <div role="tabpanel" class="tab-pane desc fade active in" id="desc"> <div class="product-description"> <?php /** @todo Test if content plugins modify the product description */ ?> <?php echo $this->product->product_desc; ?> </div> </div> <?php } // Product Description END if ($this->showReview) { ?> <div role="tabpanel" class="tab-pane review" id="review"> <?php echo $this->loadTemplate('reviews'); ?> </div> <?php } ?> </div> <div class="clear"></div> </div> <!--/. products-desc-tab--> <?php // Product Packaging $product_packaging = ''; if ($this->product->product_box) { ?> <div class="product-box"> <?php echo vmText::_('COM_VIRTUEMART_PRODUCT_UNITS_IN_BOX') .$this->product->product_box; ?> </div> <?php } // Product Packaging END ?> <?php echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'onbot')); echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products','customTitle' => true )); echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_categories','class'=> 'product-related-categories')); ?> <?php // onContentAfterDisplay event echo $this->product->event->afterDisplayContent; // Show child categories if ($this->cat_productdetails) { echo $this->loadTemplate('showcategory'); } ?> </div> <!--/.col-sm-12--> </div> <!--/.row--> <?php $j = 'jQuery(document).ready(function($) { $("form.js-recalculate").each(function(){ if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) { var id= $(this).find(\'input[name="virtuemart_product_id[]"]\').val(); Virtuemart.setproducttype($(this),id); } }); });'; //vmJsApi::addJScript('recalcReady',$j); if(VmConfig::get ('jdynupdate', TRUE)){ /** GALT * Notice for Template Developers! * Templates must set a Virtuemart.container variable as it takes part in * dynamic content update. * This variable points to a topmost element that holds other content. */ $j = "Virtuemart.container = jQuery('.productdetails-view'); Virtuemart.containerSelector = '.productdetails-view'; //Virtuemart.recalculate = true; "; vmJsApi::addJScript('ajaxContent',$j); $j = "jQuery(document).ready(function($) { $('[data-toggle=\"tooltip\"]').tooltip();Virtuemart.stopVmLoading();var msg = '';$('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);$('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);var productCustomization=$('.cd-customization'),cart=$('.cd-cart'),animating=false;initCustomization(productCustomization);$('body').on('click',function(event){if($(event.target).is('body')||$(event.target).is('.cd-gallery')){deactivateCustomization()}});function initCustomization(items){items.each(function(){var actual=$(this),addToCartBtn=actual.find('.add-to-cart'),touchSettings=actual.next('.cd-customization-trigger');addToCartBtn.on('click',function(){if(!animating){animating=true;resetCustomization(addToCartBtn);addToCartBtn.addClass('is-added').find('path').eq(0).animate({'stroke-dashoffset':0},300,function(){setTimeout(function(){updateCart();addToCartBtn.removeClass('is-added').find('.addtocart-button').on('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(){addToCartBtn.find('path').eq(0).css('stroke-dashoffset','19.79');animating=false});if($('.no-csstransitions').length>0){addToCartBtn.find('path').eq(0).css('stroke-dashoffset','19.79');animating=false}},600)})}});touchSettings.on('click',function(event){event.preventDefault();resetCustomization(addToCartBtn)})})}function resetCustomization(selectOptions){selectOptions.siblings('[data-type=\"select\"]').removeClass('is-open').end().parents('.cd-single-item').addClass('hover').parent('li').siblings('li').find('.cd-single-item').removeClass('hover').end().find('[data-type=\"select\"]').removeClass('is-open')}function deactivateCustomization(){productCustomization.parent('.cd-single-item').removeClass('hover').end().find('[data-type=\"select\"]').removeClass('is-open')}function updateCart(){(!cart.find('.total_products').hasClass('items-added'))&&cart.find('.total_products').addClass('items-added').removeClass('empty_basket');var cartItems=cart.find('span'),text=parseInt(cartItems.text())+1;cartItems.text(text)}});"; vmJsApi::addJScript('vmPreloader',$j); } echo vmJsApi::writeJS(); if ($this->product->prices['salesPrice'] > 0) { echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product, 'currency'=>$this->currency, 'showRating'=>$this->showRating)); } ?> </div>
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
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. Hello, Basicly, I want to make a php index, but make a certain redirect from it, for example, make: http://mysite.com/index.php?goto=forums Go to forums of my link choice, is their a simple code I can use? 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 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,
Can someone tell me what this redirect will do?
RewriteCond %{HTTP_HOST} ^(www\.)?website\.com/microsite$Thanks! Can anyone enlighten me on why this doesn't redirect and if there's a better / different way of achieving a redirect deep within a page?
<?php echo"anything"; // remove this echo or even make it blank and it redirects as expected header("location:blah.php"); ?> I have made a website (https://sokk.ga/), and I want to log the users public ip whenever he/she clicks one of the links, and then redirect him/her to the correct url. It's supposed to be a little php "script" between the main page and clicked link. The problem i face is that it shows the php code as plain text in the browser (chrome), no redirect or log. Here's my attempt:
<php? date_default_timezone_set("Norway/Oslo"); $ipFile = fopen("../logg/ip.txt"); $ipText = time("Y.m.d" + "-" + "H:i:s") + "-" + $_SERVER['REMOTE_ADDR'] + "\n"; fwrite("$ipText", $ipFile); fclose("../logg/ip.txt"); exit; header("https://sokk.ga/skole/"); ?> 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? Hi, I'm trying to figure out if I can get a redirect page to work, without needing to use the header("Location: page.php"); command. I know with asp, there is a response.redirect for redirecting pages, but, with the header, I can only use this, if there is no output before calling the command. Is there any method that can be used where I can process some code, if output is required, and depending on processing on the page, redirect it to another page, using a command similar to response.redirect? I have seen the http_redirect, but I can only see this working with clearing buffers etc. I have also a redirect_to("page.php"); command, but I cannot get this to work. I am using php 5. Any help would be appreciated. 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 |