PHP - Re-directing Issues
<?php
session_start( ); //Create arrays as session variables to hold form variables and errors $_SESSION['track_errors'] = array(); $_SESSION['track_form_vars'] = array(); //Clear each of the form variables posted and assign to $_SESSION['formVars'] foreach($_POST as $varname => $value) { $_SESSION['track_form_vars'][$varname] = trim($value, 50); } // Validate the First Name if (empty($_SESSION['track_form_vars'] ["invoice_number"])) // First name cannot be a null string $_SESSION['track_errors']["invoice_number"] = "You must provide us your Invoice Number"; // Validate the First Name if (empty($_SESSION['track_form_vars'] ["track_order"])) // First name cannot be a null string $_SESSION['track_errors']["track_order"] = "You must provide us your Tracking Number"; if (count($_SESSION['track_errors'])) { // There are errors. Relocate back to the client form header("Location: track_order.php"); exit; } else { } ?> <?php include "sections/header.php";?> <?php include "sections/left.php";?> <!-- start content --> <div id="content"> <h2>Track Order</h2> <?php include "connections/dbconnect.php"; $invoice_number =$_POST["invoice_number"]; $track_order =$_POST["track_order"]; $query = "SELECT * FROM customers_orders WHERE invoice_no = '$invoice_number' AND tracking_no = '$track_order'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); print " <table class='tracking_table'> <tr> <td id='name' colspan='11'> Hello ".$row['fname']." ".$row['sname']." <p></p> </td> </tr> <tr> <td colspan='11'> Please find your personal tracking information below. <p></p> </td> </tr> <tr> <th class='text'> Invoice Number </th> <th class='dots'> : </th> <td colspan='9'> ".$row['invoice_no']." </td> </tr> <tr> <th class='text'> Date Ordered <th class='dots'> : </th> <td colspan='9'> ".$row['date_of_order']." </td> </tr> <tr> <th class='text'> Status <th class='dots'> : </th> <td colspan='9'> ".$row['status']." </td> </tr> <tr> <th class='text'> Date Expected <th class='dots'> : </th> <td colspan='9'> ".$row['expected_delivery_date']." </td> </tr> <tr> <th class='text'> Vehicle Make <th class='dots'> : </th> <td colspan='9'> ".$row['vehicle_make']." </td> </tr> <tr> <th class='text'> Vehicle Model <th class='dots'> : </th> <td colspan='9'> ".$row['vehicle_ordered']." </td> </tr> <tr> <th class='text'> Vehicle Colour <th class='dots'> : </th> <td colspan='9'> ".$row['vehicle_colour']." </td> </tr> <tr> <th class='text'> Vehicle Extras <th class='dots'> : </th> <td colspan='9'> ".$row['vehicle_extras']." </td> </tr> <tr> <td colspan='11'> Please use this to track your order for speed as it will be updated as and when it comes forward or moves out immediateley. <p></p> </td> </tr> </table> "; } else { header("Location: track_order.php"); exit; } ?> </div> <!-- end content --> <?php include "sections/right.php";?> <?php include "sections/footer.php";?> Any Idea why this isn't being re-directed to "track_order.php"? Sorry if it has been mentioned previously and can I be directed to the correct information. Similar TutorialsHey guys, me again. A few of you were helping me with my login script, which I did finally get working. I am having one small problem though. Upon clicking the logout link, it does not re-direct back to the login page, it just stays blank. I have pasted my code from my logout.php file for reference. Thanks in advance for your help! Logout.php code <?php session_start(); session_destroy(); { header("location: login.php"); } exit(); ?> Hello I am having another minor issue where I am unable to spot where I am going wrong. The code for my logout button should redirect the user to index.php however I seem to be having an issue with the url. This is on my test server and I am using Code: [Select] $url = BASE_URL . 'index.php'; // Define the URL.however the button seems to be taking me to: Quote http://localhost/ICU/localhost/ICUindex.php An I am not quite sure why, the base_url should be localhost/ICU or localhost but the url given out is localhost/ICU/Localhost/ICUindex.php. why is it repeating itself? So where am I going wrong, is it in my understanding of the BASE_URL or something else? As always thank you in advance for any help. Hi all Just to let you know where I am up to currently. I have created a database for articles I want to display a a blog. I have created a blog.php page and am echoing out parts of the database. I have then created some dynamic links to display the full article on another page i've named newsarticle.php. My whole site uses includes. i.e. www.maplewebdesign.co.uk/index.php?page=home etc. I've created a sum domain - blog.maplewebdesign.co.uk but I want to re-direct this to my blog page which is www.maplewebdesign.co.uk/index.php?page=blog I hope this makes sense. I would really appriciate some help. My website is www.maplewebdesign.co.uk by the way. The blog page isn't linked yet, but the link is, www.maplewebdesign.co.uk/index.php?page=blog Thanks Adi Hi! I'm attempting to do this and feel that I'm fairly close. Would you take a look and throw me any bones? PHP Code: Code: [Select] <?php if (isset($_POST['ppassword']) && (stristr($string,'') === TRUE)) { switch($_POST['ppassword']) { case "Google": header("Location: http://www.google.com"); exit(); case "Yahoo": header("Location: http://www.yahoo.com"); exit(); case "Bing": header("Location: http://www.bing.com"); exit(); } } ?> The Form: Code: [Select] <form name="portal" id="portal" method="post" action=""> <input name="ppassword" type="text" id="ppassword" maxlength="25" onfocus="this.select()" onblur="this.value=!this.value?'company name':this.value;" value="company name" onclick="this.value=''" /> <input name="login" type="submit" id="login" value="Continue" /> </form> I appreciate any of your help. I feel close and this part Code: [Select] (stristr($string,'') feels like the missing piece of the puzzle. Perhaps I need another set of eyes on this but after Inserting into the Table (which that works fine), its not going to the next page: header("location:finalize.php"); It's inserting the new user, then staying on a blank page and not moving on to "finalize.php." Here is the code from the page: <?php session_start (); ?> <?php include('connect.php'); $username = mysql_real_escape_string($_POST[username]); $first_name = mysql_real_escape_string($_POST[first_name]); $last_name = mysql_real_escape_string($_POST[last_name]); $password = mysql_real_escape_string($_POST[password]); $membership = mysql_real_escape_string($_POST[membership]); $level = mysql_real_escape_string($_POST[level]); $terms = mysql_real_escape_string($_POST[terms]); $sql2="INSERT INTO user (first_name, last_name, username, password, membership, level, terms, date) VALUES ('$first_name', '$last_name', '$username', '$password', '$membership', '$level', '$terms', CURDATE())"; if (!mysql_query($sql2)) { die('Error: ' . mysql_error()); }else { header("location:finalize.php"); } ?> i am trying to sort out a session now, i normally use the folllowing code to check if someone is logged in and if they are not to forward them to the login page, but i am getting this message: Notice: Undefined index: username in code: Code: [Select] if ($_SESSION['username']) { }else{ include 'login.php'; die(""); } can someone help please. Hello, I'm having troubles parsing text properly. Whenever I submit data into a mysql db, and then call that specific data, in the text, I get this symbol, �. Does anybody know what it is or how to remove it? I believe it's with utf-8 and me using a function that corrupts the string but I'm not sure. Anybody have any clues? Thanks in advance. Issue # 1 How can i send the values come from $_POST['name'],$_POST['number'] to an email address xyz@radiations3.com??? Issue # 2 I am trying to display data from four different tables with the following sql query: (The problem is that the data is getting displayed fine but i don't know why some of the (same )data gets repeated two or three times where as i checked in all four tables and all the data exists one time not twice) If anything wrong with my query kindly help SELECT distinct * FROM applicant,applicant_info_nic,room,student WHERE applicant_info_nic.status='Available' and applicant.appNIC=applicant_info_nic.appNIC and applicant.roomID=room.roomID and applicant.appNIC=student.appNIC ORDER BY applicant.roomID Hey all, I can not get utf-8 working properly. I'm having issues with special characters, such as bullets, e with an accent over it, etc. The data is being stored in my mssql database properly, and I can see everything there fine. It's when I grab it from the database and display it on my php page. The page it set up to utf-8, if I go to Tools>Page Info, it says encoding is utf-8. I have it in my headers, I just can not figure out why it will not display on the page. Any thoughts? Hello, Well let me explain my problem to you guys. I am using a printf function with an array, a custom function which i got off php.net Anyways, Everytime I use it, It seems to leave random numbers at the end of the string for no reason at all. Here is the result in source: Code: [Select] <td><a href="?page=download&name=DarkRP">DarkRP</a></td> <td>08:10:17 AM 07/08/2010</td> <td>Updated DarkRP from revision: 670 to revision: 67150</td> Array ( [Name] => DarkRP [TimeStamp] => 1281186617 [Revision1] => 670 [Revision2] => 671 ) </tr>It is mean't to show Code: [Select] Updated DarkRP from revision: 670 to revision 671but instead it has the random number 50 at the end for no reason... Anyways heres the echoing code: <?php foreach($Logs as $Log){ $Time = TimeToDate($Log['TimeStamp']); if($Log['Revision1']&$Log['Revision2']){ $Message = 'Updated %1$s from revision: %3$s to revision: %4$d'; }else{ $Message = 'Freshly downloaded: %1$s revision: %3$d'; } ?> <tr> <td><?php echo '<a href="?page=download&name='. $Log['Name'] .'">'. $Log['Name'] .'</a>'; ?></td> <td><?php echo $Time['Time'] .' '. $Time['Date']; ?></td> <td><?php echo printf_array($Message, $Log); ?></td> <?php print_r($Log); ?> </tr> <?php } ?> </table> <br /> Functions: function MySQLGetLogs(){ global $Connection; if($Connection){ $Query = sprintf('SELECT name, timestamp, revision1, revision2 FROM update_logs ORDER BY timestamp DESC;'); if($Result = mysql_query($Query)){ $Array = array(); while($Row = mysql_fetch_array($Result)){ $Array2 = array(array( 'Name' => $Row['name'], 'TimeStamp' => $Row['timestamp'], 'Revision1' => $Row['revision1'], 'Revision2' => $Row['revision2'] ) ); $Array = array_merge($Array, $Array2); } mysql_free_result($Result); return $Array; } } } function printf_array($Format, $Array) { return call_user_func_array('printf', array_merge((array)$Format, $Array)); } Also, I got the same issue with printf alone instead of the custom array function above. Hey guys, I wrote a function called isServer() so I can quickly move files from my local machine to my server without modifying too much. The function is as follows: function isServer() { if ($_SERVER['SERVER_NAME'] == 'myservername') { return(true); } else { return(false); } } // isServer() I have placed this function in a system.php file I created that is used to simply to keep things in order. That files contents a <?php session_start(); function isServer() { if ($_SERVER['SERVER_NAME'] == 'myservername') { return(true); } else { return(false); } } // isServer() include "configuration.php"; include "functions.php"; include "functions_sql.php"; include "functions_soap.php"; include "functions_mail.php"; if (isProductionServer()) { $dbhost = 'db'; $dbuser = 'db_user'; $dbpass = 'pass123'; } else { $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'pass'; } $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'my_database'; mysql_select_db($dbname) or die ('Selected database does not exist'); ?> The problem I am having is for some reason none of the include files are recognizing the function. For example, the functions_mail.php file references the function to determine which emails to send (because the different environments have different modules and such installed). I know this is something easy, but I can't seem to figure it out. Thanks for any help! Hey, I'm editting some code on an OS Commerce install, For some reason I dont get the various buttons displaying. Underneath the shopping basket, it is supposed to show a view cart button and a checkout button, but they dont show up. I'm also trying to edit it to use a layout of the stylesheet, Basically if you look at my website, you will see the categories list, these are generated by an <ul><li> code, which puts the background underneath the item name, I would like to do the same thing and limit the charactors in the name to say 50 (so they stay on one line) Can you point me in the right direction to set an <li> on each item in the cart, and change it to UCWORDS, and restrict the charactors please? Any ideas on why the images dont show up on the page? http://tinyurl.com/2f6g2lg This is my code. <?php /* $Id: shopping_cart.php,v 1.18 2003/02/10 22:31:06 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <!-- shopping_cart //--> <?php // $info_box_contents = array(); // $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART); // new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART)); $cart_contents_string = ''; if ($cart->count_contents() > 0) { $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">'; $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $cart_contents_string .= '<tr><td align="right" valign="top" class="infoBoxContents">'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="infoBoxContents">'; } $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="top" class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="infoBoxContents">'; } $cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { tep_session_unregister('new_products_id_in_cart'); } } $cart_contents_string .= '</table>'; } else { $cart_contents_string .= BOX_SHOPPING_CART_EMPTY; } $info_box_contents = array(); $info_box_contents[] = array('text' => $cart_contents_string); if ($cart->count_contents() > 0) { $info_box_contents[] = array('text' => tep_draw_separator()); $info_box_contents[] = array('align' => 'right', 'text' => $currencies->format($cart->show_total()) ); //cart buttons start $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image_button ('button_cart_view.gif', IMAGE_BUTTON_CART_VIEW) . '</a>' . '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING) . '">' . tep_image_button ('button_cart_checkout.gif', IMAGE_BUTTON_CART_CHECKOUT) . '</a>' ); //cart buttons end } new infoBox($info_box_contents); ?> <!-- shopping_cart_eof //--> Hi, Okay, i have no idea what's gone wrong here - yesterday my codes were working fine, and today they arent. I have not changed a single letter of the coding on these pages but my site just isnt accepting my passwords. When i went to create a new user i noticed this at the top of the page: Quote Warning: session_start() [function.session-start]: open(/tmp/sess_28f02ccd11ec3beb8ff8b5762400b605, O_RDWR) failed: Read-only file system (30) in /home/a9203152/public_html/PHP-Login/register-form.php on line 5 but i dont really know what it is telling me is wrong? i've tried changing the file permissions etc but like i say, nothing has changed even a little bit. maybe its my computer or something?? the site is www.cumbrianadverts.com if anybody wants to try making an account to see what im talking about. any help is appreciated Thanks Hey guys im having a real problem trying to make this string happend the problem is passing parameters on the javascript function "onmouseover" $map_array .= "<a href='map.php?planet=$address' onmouseover='ajax_popup ($picture,$detail_name,$stargate_address,$detail_owner,$time_conquered,$time_offset,$detail_siege, $alliance)'> <img src='images/star.jpg' style='position:absolute; left:".$b_x."px; top:".$b_y."px; border-style:solid; border-color: yellow;'></a>"; if I try this it works onmouseover='ajax_popup(1,2,3,4,5,6,7,8)'> So the problem is when the variables equal words. Cause of the quote issue. Is there like a way i should be using JSON to do what im trying to do? I have to keep this as a php string too. Or end as a php string Hello, I have the following code Code: [Select] class Uploads extends Controller { public function __construct() { parent::__construct(); if (empty($_FILES)) { log_message('error', 'Uploads - files empty'); exit('No files uploaded'); } ini_set('memory_limit', '128M'); $this->load->helper('file'); $this->load->helper('helpers'); $this->load->model('uploads_model'); } public function font_handler() { $this->uploads_model->font_handler(); } } class Uploads_model extends Model { public function font_handler() { $config = array( 'max_size' => '8388', 'allowed_types' => 'ttf', 'upload_path' => 'assets/fonts/' ); $this->load->library('upload', $config); if ($this->upload->do_upload('Filedata')) { $file = $this->upload->data(); $jsFile = $file['raw_name'].'.js'; $query = $this->db->where('location', 'menuFont')->get('fonts')->row(); if ($query->customFile != '' && file_exists('assets/fonts/'.$query->customFile)) { unlink('assets/fonts/'.$query->customFile); } $path = getcwd() . '/assets/fonts/cufon/convert.php'; $command = 'php ' . $path . ' -u "U+??" ' . $file['full_path'] . ' 1> ' . getcwd() . '/assets/fonts/' . $jsFile; system($command); } } } Ok so, the ttf file is uploaded correctly and I can run $command from the command promt in putty and it works perfect, but when I try to run the same command from system() the js file just contains (from the controller) "No files uploaded" I have no idea why this is happening? Anyone have any ideas? Also one thing i'm not sure about is if it should be 1> or > when creating the js file?!? Thanks guys! Code: [Select] OFXAdapter: Failed to parse request: Unable to parse an atomic field "OFXRequest.OFXRequest.SignOnMsgsRqUn.SignOnMsgsRqV1.SonRq.DtClient": field value "20101005091544.000[-4:EDT]" is not a valid (YYYYMMDDHHMMSS.XXX[gmt offset:tz name]) date. I am trying to put together some PHP code to use the OFX standard to communicate with my bank in order to download my recent transactions. The standard details that in the sign-on request, the date and time must be included in the format listed above. As you can see, I have the value in the exact same format as specified. So my question is this: is there something about GMT offset or TZ names that I am missing here? Thanks for taking the time to read the thread. Basically the situation is with the following code: Line 1: print(self::$internal_commands[$command_value]); Line 2: print(self::$internal_commands[":!modules"]); This will output the following: Code: [Select] Line 1: PHP Notice: Undefined index: :!modules in /var/www/html/MagicIRC/Framework/commands.class.php on line 36 Line 2: Commands_Framework::command_loadedmods Notice how the first notice tells you that ':!modules' isn't in the array yet the second print statement below it prints fine and the var $command_value is being supplied the same string as what the manually input print statement is? I'm trying to write a function that'll give me the days of the week of any submitted date. This keep returning 1/30/2011 even though I am submitting 1/05/2011 (the Monday should be 1/03/2011)...I know it's incomplete I'm just trying to get the Monday right now Code: [Select] function getWeekDays($date) { //convert string to date $thisdate = date($date); $dow = idate('w', mktime(0,0,0,$thisdate)); if ($dow == 1) { $monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate), date('Y'))); } else if ($dow == 2) { $monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 1, date('Y'))); } else if ($dow == 3) { $monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 2, date('Y'))); } else if ($dow == 4) { $monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 3, date('Y'))); } else if ($dow == 5) { $monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 4, date('Y'))); } $weekarray = array($thisdate); return $weekarray; } Im trying to make a multiforum software for phpBB and im stuck. Ive been trying to figure this out for HOURS and still, I end up with f**king syntax errors. Kind of hard to explain. If they visit forumname.terraboards.com then it will load their forum tables. But instead I end up with errors. The codes I tried does not work. Now I don't know where to start.s I feel like im trying to create a impossible triangle. Is there any solution? My Code: $serverurl = $_SERVER["HTTP_HOST"]; $forumurl = "SELECT * FROM 'forumaccounts' WHERE forumurl LIKE '. $serverurl .'"; $result=mysql_query($sql, $con) or die(mysql_error()); while ($row=mysql_fetch_array($result)) { if ($_SERVER["HTTP_HOST"] == '$row["forumurl"];') { $dbms = 'mysqli'; $dbhost = 'localhost'; $dbport = ''; $dbname = '***_phpbbmulti'; $dbuser = '***_phpbbm'; $dbpasswd = '****'; $table_prefix = '$row["forumprefix"];'; $acm_type = 'file'; $load_extensions = ''; } else { die ("Invalid forum"); } } I'm going to post two scripts my login.php and my register.php problem is i'm always getting usernamepassword don't match i think something to do with md5 but can't figure out where... or why? <?php session_start(); $login = $_POST['login']; $password = $_POST['password']; if ($login&&$password) { $connect = mysql_connect("localhost","heaven","jefF0614") or die ("could not connect to server"); mysql_select_db("heaven_users") or die ("could not find database"); $query = mysql_query("SELECT * FROM members WHERE username='$login'"); $numrows = mysql_num_rows($query); if($numrows!=0) { while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } // check to see if they match if($login==$dbusername&&$password==$dbpassword) { echo "Your In <a href='member.php'>click here to go to the member page</a>"; //start session $_SESSION['username']=$login; } else echo "Incorrect Password/Username Combination"; } else die("That username dose not exist"); } else die ("Please enter a username and password"); ?> and register.php <?php //check for submit $submit =$_POST['submit']; //gather POST variable $fullname =strip_tags($_POST['fullname']); $email =strip_tags($_POST['email']); $username =strip_tags($_POST['username']); $password =strip_tags($_POST['password']); $password2 =strip_tags($_POST['password2']); if ($submit) { //check that fields were filled in if ($fullname&&$email&&$username&&$password&&$password2) { //check to see if our two password fields match if ($password==$password2) { $password = md5($password); // register the user //open database $connect = mysql_connect("localhost", "heaven", "jefF0614"); mysql_select_db("heaven_users"); //begine insert $queryreg = mysql_query("INSERT INTO members VALUES ('','$fullname','$email','$username','$password')"); if ($queryreg) { echo "Thanks, For Registering! Click <a href=\"index.php\">HERE</a>To Login!"; } } //otherwise if passwords don't match else { echo "<font color='red'>The passwords you entered do not match</font>"; //end of checking password } } else { echo "<font color='red'>Please enter all fields!</font>"; } } //end check for submit ?> |