PHP - Url Setting
I made a website in PHP mvc framework. Now I want to remove "public" keyword from URL. I tried by removing require "../app/init.php"; these dots and bringing htaccess & index.php file in root directory. But it doesn't work. I searched on google but didn't find anything. Here is my index page code: Quote
<?php require "../app/init.php"; $app = new App();
and my htaccess code: Quote RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f Please give me a solution to it. Thank you Similar Tutorialscan anyone tell me why $username is not setting properly? the password is, but $username is no. it is setting as blank: Code: [Select] if ($_POST['go']) { //Connect to the database through our include if ($_POST['logid'] == ";5757120050531338739=49121200000?"){ $username="oldcheney"; $username = stripslashes($username); $username = strip_tags($username); $username= strtolower($username); $username = mysql_real_escape_string($username); $password="password";} else if($_POST['logid']==";5757120050531338721=49121200000?"){ $username="yankeehill"; $password="password";} else if($_POST['logid']=="%6277202936423578^00000000^X?"){ $username="holdrege"; $password="password";} $password = md5($password); Is it posible?! I'm sure it can be done. Description of the problem's frame: A server , multiple nic's with IPa , IPb, IPc. The problem : More than one PHP scripts running in the same time ,but ... I use scriptA I want it to use NICa with IPa to connect somewhere. Then I also want scriptB to connect to the same place but from another IP. I don't want to use proxies or other stuff. Just want to use a specific network card. In C it is posible to choose one. Thank you for your time. Well this isn't all about cookies or maybe it is, I'm not to sure. On top of this my script has suddenly broke and stops at check.php I'm also not sure how I should go about checking the cookie to identify the user and how to keep other from viewing the output page(s). Code: (index.html) [Select] <html> <head> <title>Deadnode.com</title> <style type="text/css"> img { position:absolute; left:300px; top:130px; z-index:-1; } form { position:absolute; left:365px; top:248px; z-index:0; } </style> </head> <body> <img src="iL0bw.png" /> <form method="post" action="check.php"> <center><table> <tr><td><font face="verdana,arial" size=-1>Username:</td><td><input type="text" size="25" name="user"></td> <tr><td><font face="verdana,arial" size=-1>Password:</td><td><input type="password" size="25" name="pwd"></td> <tr><td><font face="verdana,arial" size=-1> </td><td><font face="verdana,arial" size=-1><input type="submit" value="Login"></td></tr> </table></center> </form> </body> </html> Code: (function.php) [Select] <?php function check() { $admin="test"; $pass="test"; if (isset($_POST["user"]) && $_POST["user"] == $admin && isset($_POST["pwd"]) && $_POST["pwd"] == $pass) { header('Location: output.php'); setcookie("usr", "test", time()+3600); else { header('Location: index.html'); } } ?> Code: (check.php) [Select] <?php require('function.php'); check(); ?> Code: (output.php) [Select] <?php require('check.php'); ?> <html> <body> <p>Congrats!</p> </body> </html> Hello, My latest issue is with a login page I am trying to set a cookie for. I have deduced that it it pulling my info out of my database correctly. It does not give any errors for username or password when they are entered correctly but when I get to the end of the script where I would like to set a cookie and redirect to a new page it just stays on the same page and appears as if it is loading but nothing happens. After I stop the browser and attempt to reload the page it gives me an error saying the page cannot be displayed. Do I need to specify anything before I can have the following code work or is it that it is clashing somewhere else along the way? Code: [Select] <?php else { // if login good set cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //then redirect them to the members area header("Location: http://example.com/"); die(); } ?> If I remove this code and simply leave the redirect as shown above, it works. But that defeats the purpose of the script as on the redirected page there has to be a cookie set to display it. Any help would be appreciated Hi, I'm trying to set cookie but all in vain. I've already posted my php code in my last post. "COOKIE PROBLEM". I think there is nothing wrong with code. may be i need to enable to load some library or something in xampp. Is there anyone who knows what setting do i need to do for enable cookies and in which file? Please help I am trying to make a login using cookies, I had been using sessions but i need to use cookies for it now. I have a page called login.php, and i use ajax to login. It seems to be setting the cookie and printing the value of it out when i login, however that's about it. When i'm reading the cookie on other pages it doesn't appear to recognize a cookie. However, If i set the cookie on just a regular index page it has no problem with setting it and reading it. it works fine when i do that. This is how i set the cookie on the login page (also the exact code i used to test setting it on the index page): $expire=time()+60*60*24*30; setcookie("id", $dbid, $expire); $session = $_COOKIE['id']; then to read it on other pages i just use: $session = $_COOKIE['id']; hello, ok if i set a Global on index.php (wwwroot/admin/index.php) it works Code: [Select] $page1='hello from page1 on index'; global $page1; echo $page1; i can echo $page1 on other pages like (wwwroot/admin/pages/home.php) and it will echo out "hello from page1 on index". GREAT but if i write a Global on (wwwroot/admin/pages/home.php) it does not work. i also can not echo it out on any other page Code: [Select] $page2='hello from page2 on home'; global $page2; echo $page2; why is this ??? Hi I was wondering how I could set up a time mod to set time 3 times per hour. DROP TABLE IF EXISTS og_updateattacks; CREATE TABLE og_updateattacks ( lasttime int(20) default NULL, id int(11) NOT NULL auto_increment, PRIMARY KEY (id) ) TYPE=MyISAM; That is what I got, but I want it so users can attack at random times per hour. I have created my lottery script. At the moment i simply have the time() function being used where the draw will happen. Im wondering if your able to get rid of that and just choose a particular time where i want the draw to happen. I want the draw to be done at 4pm everyday. (in GMT) Is this possible? and what would the right code be for it. I am trying to separate this information by the "-" symbol so that I can insert it. This output would be ideal. Any help today? 105-2-2-3-Cheerleading $value[0] should = 105 $value[1] should= 2 $value[2] should= 2 $value[3] should= 3 $value[4] should= Cheerleading I have tried many approaches and come up with notta 105-Athletics 105-1-Eagle Sports 105-2-Programs 105-2-1-Boys 105-2-1-1-Football 105-2-1-2-Cross Country 105-2-1-3-Golf 105-2-1-4-Basketball 105-2-1-5-Baseball 105-2-1-6-Track 105-2-1-7-Tennis 105-2-2-Girls 105-2-2-1-Volleyball 105-2-2-2-Golf 105-2-2-3-Cheerleading 105-2-2-4-Basketball 105-2-2-5-Softball 105-2-2-6-Track 105-2-2-7-Tennis 105-3-Coaches 105-4-FHSAA 105-5-Game Directions Thank you for looking. hi i wants to disable open_base_dir for my folder /home/admin/mysite.com/myfolder/ so in myfolder script i could use CURLOPT_FOLLOWLOCATION I can disable open_base_dir in my kloxo panel but i would like to use it this way, I modified my php.ini file and set this path open_basedir = /home/admin/mysite.com/folder/ but still i get error while using CURLOPT_FOLLOWLOCATION Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in Please any help on how to disable that in /myfolder.? using Centos 5 Thanks I've been working on this for the last few hours and haven't had much luck. Basically, every time you visit the index of my site a random image is shown. The images are stored in a directory, and i use a table to hold the id, name, and url of each image. When the index page is loaded a random int is chosen, and the id equal to the int prints the corresponding url for the image. Now i'm trying to add the id into the url, "domain.com?img=1". I also need this url to always refer to the image in row 1. My table is called uploaded_images and the columns are id(primary key), name, url. I'm pretty lost, any help is greatly appreciated. v=$("#txtusername"); $.post('../actions/check.php',{user:v.val().toLowerCase()},function(d){ if(d=='available'){ $("#usernamemessage").html("<span style='color:green;'>Username is available</span>"); }else if(d=='not-available'){ $( "#txtusername" ).effect( "shake" ); $('#txtusername').css('border', 'solid 2px blue'); var iserror = '1' alert(iserror); } }); alert(iserror);The first alert displays '1', however, the second displays 'undefined'. Why is this? Thanks HI all i have the following code: <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); if (session_status() == PHP_SESSION_NONE) { session_start(); } if (!isset($_SESSION['user_name'])){ header("location: index.php"); } mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); include '../_includes/dbconn.php'; if($_SERVER['REQUEST_METHOD']=='POST'){ if(isset($_POST['delete-equipment-button'])){ $eid = $_POST['EM-id']; $stmt = $conn->prepare(" SELECT a.equipment_id, b.equipment_name from ssm_equipment_order a inner join ssm_equipment b on a.equipment_id = b.equipment_id where a.equipment_id = ? "); $stmt->bind_param('i', $eid); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($eid, $eqname); $stmt->fetch(); $instances = $stmt->num_rows; $_SESSION['eqname']="$eqname"; if($instances>0){ $_SESSION['updateEquipment']="is being used in an active order and cannot be deleted"; header("location: ../equipment-list.php"); }else{ $_SESSION['updateEquipment']="has been successfully deleted"; $stmt = $conn->prepare(" DELETE FROM ssm_equipment WHERE equipment_id = ? "); $stmt->bind_param('i', $eid); $stmt->execute(); var_dump($_SESSION); // header("location: ../equipment-list.php"); } } } ?> The session variable eqname gets set properly when the delete fails (the first half of my if). When i get to the else, the session does not set a value. I assumed that it was because the item whose name i am trying to get is being deleted but i thought this would happen after i have set the session variable and therefore be preserved for when i get back to the equipment list? As always, i appreciate your help. hi i have set up my1 st member area (www.sittonjewelryshop.com). everything works fine except of 1 thing with the checkuser and the verify php files. i have set it up that if some one is trying to go directly to the member area without register it wont let him and send him to the login area but for some reasson it doesnt work. if you write www.sittonjewelryshop.com/member/login_success.php it takes you directly to the membera area. was trying to manipulate verify.php and register.php but could find the problem. any suggestion? tnx. Hi, I'm pretty new to php, and to this site as well, so please bear with me... I have a table in my database which has "user_id" as its primary key, and i want to set the values under this as a cookie. I've put in bold the main things that are affecting it (I think). As is, the mysite_userid cookie does not set properly, and I get an error like this "Header may not contain more than a single header, new line detected...." Any help would be really appreciated!! <?php include("connect.php"); $match = "select user_id from $table where username = '".$_POST['username']."' and password = '".$_POST['password']."';"; $qry = mysql_query($match) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows <= 0) { echo "Sorry, there is no username ".$_POST['username']." with the specified password. "; echo "Try again"; exit; } $remember = strip_tags($_POST['remember']); if ($remember) { setcookie("loggedin", "TRUE", time()+3600*24); setcookie("mysite_username", "".$_POST['username'].""); header("Location: members.php"); } else { setcookie("loggedin", "TRUE"); setcookie("mysite_username", "".$_POST['username'].""); setcookie("mysite_userid", $qry); $site_username = $HTTP_COOKIE_VARS["mysite_username"]; $site_userid = $HTTP_COOKIE_VARS["mysite_userid"]; header("Location: members.php?user=$site_userid"); } ?> This topic has been moved to PHP Installation & Configuration. http://www.phpfreaks.com/forums/index.php?topic=309993.0 ok, I run a samp server that has mysql and i'm creating a website to register on the server, Ok, I got it so you can set your charcter age (it's a role play server) but i need help with setting fighting styles, The gamemode uses pawno scirpt lang and the values i use to set each fighting style is 5,6,15 and 26. I have it set it a drop down menu, I want to convert this code so it shows certian names and when you select those certian names it sets the value for that name Here is the code for my age but i want set to like i said above </select> <tr> <td><b>Age:</b></td> <td><select name="age"> <option value="---">Fighting Style</option> '; for ($i=18;$i<99;$i++) { $metai = date('Y') - $i; echo '<option value="'. $i .'">'. $i .' (' .$metai. ')</option> '; } echo ' </select> Instead of it outputting the Age and the Year i want it to Output those values i mention before and the style Example These are in the drop down menu Kung_Fu (6) Elbow (26) Boxing (5) Kick Boxing (6) When you select it, It writes to the database I am sorry I have absolutely no idea where this question fits in this forum bcoz its related to PHP , MySQL and Javascript... So here is my question .. I use MySql database to store posts.. where 'postdate and time' is saved using 'CURRENT_TIMESTAMP' of MySql that offcourse gives "2010-08-31 09:47:10" format... When I have to calculate when the post was posted just before loading the posts on users wall e.g. "2 min ago"... I take the 'postdate and time' from database then use strtotime() function in php to convert it to string you know since jan 1 1970. Now this time stamp is sent to javascript function which uses 'Date' Object to create current time and then 'getTime' to get the string like one Mentioned earlier. it then calculates the difference and displays it.. Just to inform you.. I used javascript to I may refresh "posted since" periodically using "SetInterval()" But the problem here arises. There is difference of 1 Hour and 24 Sec in both times....... Sorry If I confused you... But the problem is simple. In javascript date object and MySql --> strtotime() there is time difference... How I can correct it ??? please Help ... Codes: 1. function to convert str to time function change($date){ $time_early=strtotime($date); return $time_early; } 2. javascript Code to check "Post Since" function calc_difference() { $("[name=posttime]").each(function() { var current=$(this).attr("id"); localtimevalue = new Date(); d = localtimevalue.getTime(); var d= parseInt(d)/1000; var diff=d-parseInt(current); var diff=parseInt(diff); var min=parseInt(diff/60); var hours=parseInt(diff/3600); var days=parseInt(diff/86400); var months=parseInt(diff/2592000); var years=parseInt(diff/31104000); if( min==0 ){ $(this).text("Posted: "+diff +" seconds ago "); } if(min>0 && hours==0 && days==0 && months==0){ if(min==1){ $(this).text("Posted: a minute ago "); }else{ $(this).text("Posted: "+min +" minutes ago "); } } if(min>0 && hours>0 && days==0 && months==0){ if(hours==1){ $(this).text("Posted: an hour ago "); }else{ $(this).text("Posted: "+hours +" hours ago "); } } if(days>0 && months==0 && years==0){ if(days==1){ $(this).text("Posted: a day ago "); }else{ $(this).text("Posted: "+days +" days ago "); } } if(months>0 && years==0 ){ if(months==1){ $(this).text("Posted: a month ago "); }else{ $(this).text("Posted: "+months +" months ago "); } } if(years>0){ if(years==1){ $(this).text("Posted: a year ago "); }else{ $(this).text("Posted: "+years +" years ago "); } } }); } Javascript function is called on load and Jquery's .each function is used to update all post's time. having a problem figuring out how to change the default on a drop down box to equal the users current timezone. So when they view it the drop box default is showing what their setting is atm. The problem is the value is differant from whats displayed. Is it possible to some how say if users time offset is equal to a option value set selected=""> to yes. if not what is the idea behind this? Cant find a guide showing an example In other drop down boxes where the value is the same as whats displayed I just simply created another value field at the top of the list and echo it in. Code: [Select] <select name="gmt"> <option value="-28800">(GMT -0800) Pacific Time </option> <option value="-25200">(GMT -0700) Mountain Time </option> <option value="-21600">(GMT -0600) Central Time</option> <option value="-18000">(GMT -0500) Eastern Time </option> </select> |