Domain Checking Problem : $_SERVER["PHP_SELF"]
I'm trying to insert some html if the browser location is my top level domain (www.mydomain.com) only, and I have the following code which appears not to work :-(
Can anyone cast an eye over it?
<?
$spacecheck = $_SERVER["PHP_SELF"]
if $spacecheck = "/" {
echo ('<td height="27"></td>')
} else {}
?>
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Error In Page When Checking Http_get_vars("myvar") And "myvar" Was Not Passed In URL String
PHP, coming from ASP coding if (HTTP_GET_VARS['b']==1){ print "Yes"; }else{ print "No"; } when "b" is not passed via (http://www.mydomain.com?b=1 an error occurs and the "NO" is printed but an error is printed too. How can I check for the value of "b" so that no error occurs if b is not passed?? example http=www.mydomain.com $myvar=HTTP_GET_VARS['b'] causes an error because "b" does not exist (ie. its not passed in the URL string. $myvar maybe evaluated as NULL or Empty but the error is printed in the page, anyway.
How To Redirect Based On $_SERVER["HTTP_REFERER"]?
I have a page that I don't want anyone to be able to link directly to. The page should only be accessed from gatepage.php. I tried this code, but keep getting errors - "header info already sent", or something like that... Am I missing something, or is there a better way to do this? <?php $ref = $_SERVER["HTTP_REFERER"]; //echo $ref; if ( $ref == 'http://www.mydomain.com/gatepage.php' ) { //record visit } else { //send to gatepage.php header("Location:http://www.somegatepage.com"); exit; } ?>
Turn On $_SERVER["PHP_AUTH_USER"] Locally?
I am finding that on a new server where I am developing $_SERVER["PHP_AUTH_USER"] and $_SERVER["PHP_AUTH_PW"] Do not show up in $_SERVER when I when they should be defined I test using print_r($_SERVER) or this <?php if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Text to send if user hits Cancel button' exit; } else { echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>"; echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>"; } ?> Is there a setting that is keeping PHP from accessing this information? Can I set this locally? $_SERVER["REMOTE_USER"] also stays empty.
$PHP_SELF + Header("Location:");
Is it possible to user $PHP_SELF and then in if($_POST) can i use header("Location:"blah.php); as i really cant get it to work Code:
How Much Can I Trust $_SERVER["AUTH_USER"]
I'm using PHP 4.1.1 with IIS. When I create a protected directory with IIS, you can choose NT Authentication. Doing so creates $_SERVER["AUTH_USER"] and $_SERVER["LOGON_USER"] set to something like GUAVAJohn So how much can I trust this variable? At work, everyone has to log onto the NT domain in order to get on the computers. So if I protect the directory and then check for this variable, can I assume that the user is valid for the domain and identify them by this name? Then I don't have to prompt for a password...
$ SERVER["REQUEST URI"] Includes Domain Unexpectedly
In my old server running Apache 1.3 and PHP 4 this code will return just the URI as expected: $_SERVER["REQUEST_URI"] = "/some-html-file.html" In my new server with Apache 2 & PHP 4 this code returns the domain: $_SERVER["REQUEST_URI"] = "/full-domain-name.com/some-html-file.html" Does anyone know a way to change things so the code will not return the domain name and whether this is because of PHP or Apache that I'm suddenly getting the full domain name?
Help With Setcookie() And "stealth" Domain Forwarding
I cannot get setcookie() to work with the way my domain is setup. My domain forwards to a subdomain of another domain. www.mydomain.com -> mydomain.host.com The problem is the way I have the forward setup, using "stealth" URL forwarding, it only shows "www.mydomain.com" as the URL. With it setup this way, I cannot get setcookie() to work. I do not want it to display "mydomain.host.com" in the URL, I want to have it as www.mydomain.com Any work arounds?
How Do I Do Something Like $color = ("red", "yellow", "blue")[$colornum]?
How do I take an index of a literal array, instead of a variable? That is, say I want to get the short name of a month. Can I do something like: $monthname = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[$month]; or do I always have to do: $blah = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $monthname = $blah[$month]; It seems a shame to have to create a variable specifically for this one-shot purpose.
Checking "last Updated" On Remote Files.
How do I check the last updated time on remote files. I'd like my end result to be, a function that takes a list of urls, check the lastupdated date on that file (i.e., home page of someone's blog), so I can then grab the ten most recently updated among them, and print them, in descending order of update date.
Action="<?=$PHP_SELF?>">
Can not determine how "<?=PHP_SELF?>" is supposed to work. The below is the line of code. <!-- <form name="search" method="post" action="<?=$PHP_SELF?>"--> When the above statement is run the following is the result. You don't have permission to access /dev/forms/forms_testing/< on this server.
Domain "Extension" Array
I want to take input from $_POST['website'] and put it in a variable, then I want to check whether or not one of these domain extensions were entered (of course there are more than 6 extensions, but this is for testing). Is there a better way of doing this or am I on the right path? //validate website posted. Domain was entered. $website = $_POST['website']; $domains = array("com", "net", "org", "edu", "us", "biz"); if (!in_array($website, $domains)) { $error .= "<p class='error'>Enter the web address in the correct format.</p>"; }
Checking An Array And "splitting It Up"
I'm trying to create an image upload class and got into a little array problem. (File is attached to post. Sorry for the Icelandic) I pass the $_FILES['someuploadfiles'] to $this->uploadskrar and then in skoda() I cycle through the array and the if/else sentence is to filter out the bad apples, the images that don't f meet the standards set, $this->ilagi_myndir is for pictures that meet the standards and $this->nilagi_myndir is for pictures that don't meet them. Those 2 arrays are are suppose to have the same structure as $this->uploadskrar and i'm not figuring out how.
Checking If $user & $pass = " "
if !( $user=="" || $pass==""); mysql_query("INSERT INTO users (id, sn, pw) VALUES ( '$idhigh + 1', '$user', '$pass')"); It wont load up my page when I try to run it with this in my page, what am I doing wrong? It checks my text boxes to see if the user and pass equals a blank input when the person clicks on the submit button, and if it does, then it does nothing.
Preventing Visitors Ability To "re-visit" A Page Via The "back Button"..
I have a rather complex registration/member sign up form.. which gets a little confused, when a visitor "backs" completely out of the form, then for whatever reason returns to the form. The form contains 'cancel' buttons, which naturally cancel the reg process and redirects them to the document just before they started. JS provides us with the "location.replace()" method, but I can't seem to find a way to coordinate the use of location.replace() with the posting of the form values. In short, I want to "replace" the first step of the form with the "second step". I think what's making this tricky, is that each step of the form are located within the "same" page (register.php). The document works like so: The first step is the "Member Agreement" when they click "agree" (submit) the system creates a new row in the temporary register table of the db. It then issues a registration cookie, which carries the row id, and session value. in addition (for those cookie impared users) we carry the row id and session value in hidden elements. So far, as long as the user continues through the process all is fine, but if they (for whatever reason) back all the way out, and click 'agree' again, the process fails. I guess I have to find a way to force a reload of the 1st step "if they've gone back" OR "replace()" the first step with the second, so as to prevent the user from going "back" to the 1st step of the register page.
Pagnation - Limit Number Of Pages Between "Previous" & "Next" Hyperlinks
Was hoping for some advice with a part of page navigation.... It works at the moment so there is a "Previous" & "Next" Hyperlink underneath the records. In between the Previous & Next links are the number of pages that there is of these records. e.g: Previous 1234 Next This is fine if there are only a few pages of records, but when there are hundreds of pages the numbers are listed and they take up half the web page with them. How can i make it so only limited 10 numbers of pages say appear between the "Previous" & "Next" Hyperlink and as you progress through the pages they are as do the next 10 numbers of pages? Code:
[regex] Stripping Out "name" And "value" Values Out Of Tags, Aaargh
Searched through the site, but couldn't find the right regex syntax I was looking for. the thing i want is, to extract with preg_match_all the given values in a tag... ex. $str = '<input type="text" name="name" value="value">' $pattern = some magic stuff I need to know preg_match_all($pattern, $str, $result); And in result I want to have the values text, name and value AND it's important that the order doesn't matter so structure of tags can be <input type =name= value=> or <input name= class= value= type=> etc, etc...
'Parse Error' Problem In "isset" And "empty"
I've been having some problems with a parse error that I can't figure out (PHP 4.3.11 on Solaris9). Sample code: <?php // getting strange parse errors on this class A { var $value; function A() { $this->value = 1; } function getValue() { return $this->value; } } $a = new A(); if (!empty($a->getValue())) { echo "success"; } else { echo "failure"; } ?> The result of this is: Parse error: parse error, unexpected '(', expecting ')' in /foo/public_html/parse_errors.php on line 15 I also get the same effect with "isset", however, testing with "is_null" or "is_int" produces the correct ("success"/"failure") result. Any ideas?
Echo "<!--#include File="top.html" -->";
I have a search script which returns a page of results, however I'd like the returned page to be in the same format as the rest of my site. To do this I've tried adding the HTML for my site to my PHP page with echo" " commands. This works for the plain HTML, but my regular pages also use SSI to do other stuff (some of them even execute other PHP scripts to generate tables of data etc). I've tried echo "<!--#include file="top.html" -->"; but it doesn't work as I get a parse error. My question is, how do I go about doing this properly? Is this possible at all? And if not have you guys got any suggestions to get around this?
Any File Size Limit In <PARAM Name="***" Value="***"> ?
I embed an applet in my php script which has a parameter providing an input file for the jar. Does this file has size limit? The code is as follows: <APPLET ARCHIVE="myapplet.jar" WIDTH=372 HEIGHT=360 VSPACE=0 HSPACE=0 ALIGN=middle> <?php echo "<PARAM NAME="data" VALUE="myfile.">";?> when "myfile" is beyond 15M, my applet cannot load sucessfully, but while this file is limited like 5M or 7M, it works well. Does anybody know is the reason caused by php script limit, applet mechanism, or by different browser?
How To Do PHP "require()" Or TCL "source" In Bash Script
I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or TCL's "source". This is what I have so far and it fails: if [ -f ivc.cfg ]; then cat ivc.cfg fi Anyone really know bash script well please help, it's a barrier for me not to be able to get just this one piece working.
Coding "NEXT" And "PREVOIUS" Buttons
Hi I am stuck here. I am doing a form which dispalys details of client companies. My query includes this statement: .... WHERE CompanyName LIKE %$name% .... What I need is following: if a query returns more then one result I what to "flip" through result with NEXT and PREVIOUS buttons.
Mysql/php - "LIMIT" And "ORDER"
In the following fragment of code, I am querying a database that in order to display a list of films. The list is very long and I would like to offer the possbility to restrain the range of results showned by page keeping in mind that the user should be able to browse forward or backward data if applicable. I know that I have to add the LIMIT method in the MySQL query but I have a hard time figuring how not to get lost in setting it dynamically in the PHP script. Then I have a second question. Is there a more elegant / straightforward way to deal with the display order of the data (cf. $ot, $od and $oy)? Code:
Sticking "if" Or Changes Within A MySQL "where" Array?
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit, you'll see a lot of results. And I have HR's dividing each entry. What I need to do is group all the entries of the same year, or at least only put HR's between the blocks of years. So, I'd have all the entries for 2002, an HR, then all for 2001, an HR, etc. Here at the bottom I'll include my PHP code I'm using so far. But I have no idea where to even start looking for an answer...if it's even possible. If someone can just give me the name of the function or process or technique, then I can go Web/book searching myself...I just need a direction of where to go. PHP:------------------------------------------------------------------------ ------ $query_RS_award = "SELECT * FROM $award WHERE id != Ƈ' ORDER BY year DESC, w DESC"; //$query_RS_award = "SELECT * FROM $award WHERE year = "$year""; $RS_award = @mysql_query($query_RS_award, $connection) or die("Couldn't query: " . mysql_error()); $totalRows_RS1 = mysql_num_rows($RS_award); while ($row_RS_award = mysql_fetch_assoc($RS_award)) { $award_id = $row_RS_award['id']; $award_tblid = $row_RS_award['tblid']; $award_award = $row_RS_award['award']; $award_year = $row_RS_award['year']; $award_category = $row_RS_award['category']; $award_won = $row_RS_award['w']; $award_film = $row_RS_award['film']; $award_nominee = $row_RS_award['nominee']; $award_note = $row_RS_award['note']; if (!($award_category)) { $award_category = "n/a"; } else { $award_category = $award_category; } if ($award_won == "1") { $award_won = " - Award Winner"; } else { $award_won = ""; } $display_block_Award .= "YEAR: <span class='normalText12White'>$award_year</span><br>FILM: <span class='normalText12White'>$award_film</span><br>CATEGORY: <span class='normalText12White'>$award_category</span><br>NOMINEE: <span class='normalText12White'>$award_nominee</span><span class='normalText12BoldWhite'>$award_won</span><br><blockquote><span class='normalText12White'>$award_note</span></blockquote><hr>"; }
Cookies And "include" Or "require"
i'm having a problem with my setcookie() instructions. Although there are absolutely no html tags in front of them,for some reason PHP3 sends me back the message "oops...php3_SetCookie called after header has been sent"... I do however use two "require" calls, one to a file with a .php extension, and one to a file with an .inc extension. At the beginning of each files there's a Could the cookie failure and the include functions be related ? In my text, I have even wiped out any HTML tags such as "bold, paragraph, line break" tags, even in "echo" commands, but to no avail what am i doing wrong ?
FTP_login + $pass="" And $user=""
I use the following scrit in an Intranet with the user name = "" and the password = "" : <?php $ftp_server = "192.168.25.25"; $ftp_user = ""; $ftp_pass = ""; $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { echo "Connected at $ftp_user@$ftp_server "; } else { echo "Can't connect with $ftp_user "; } ?> I have the following message : Connected to 192.168.25.25 Warning: ftp_login(): 'USER': Invalid number of parameters in E:www est_ftp.php on line 26 I tried to : ftp_login($conn_id, "", "") but i have the same result...
Why Use "Stripslashes" And "Addslashes" Function
Can someone let me know why one would use strip slashes or add slashes functions. I know what they do but cannot see the exact use for them e.g. if i have a textfield and encase it in an stripslashes function, it will escape any back slashes etc...
$_SERVER['PHP_SELF'] Vs $SERVER[PHP_SELF]
I am moving a script to a different server. This works on the old server $_SERVER ['PHP_SELF '] but not on the new. If I do it this way on the new it works $_SERVER[PHP_SELF]. I was up rather late last night attempting to figure this out. Any help would certainly be appreciated as I fear it is something obvious to everyone but me.
Parse Errors With "case "action":
I want to call an action that is in a file called "configm.php" but I get a parse error on line 8. (the bit that goes 'case "add":') Code:
Adding Domain Name In <a Href="
Say $content contain a html page that have a lot of <a href="here"> bla bla bla <a href="there"> Say, my domain name is "http://domain.com" I want to change <a href="here"> into <a href="http://domain.com/here"> What would be the most efficient way to do so? What about if I want to do it only to one of the anchor?
How To Count "Hit" And "View"
I would like to know when a user logs in, he clicks Mike's E-mail. It will count one which mean "Hit". So that I will be able to know how many times users click Mike's E-mail. Like Sitepoint. When other users read other problems. Views will count 1. I would like to know how to do it. Could you explain with script?
"echo" Or "print" ?
Can tell me someone is some big different between "echo" and "print". What You prefer to use?
$_server[php_self]
i'm having issues with this returned function. I can get it to delete a database but i really want it to grab the stateselect extention and grab all the cities related to that state. I wanted to contain this on one page instead of going over multiple pages which i can do. Sorry if this doesn't make much sense i'm a newbie.. below is the code. the isset($_get <?php $dbcnx = @mysql_connect('localhost', 'root', ''); if (!$dbcnx) { die( '<p>Unable to connect to the ' . 'database server at this time.</p>' ); } // Select the hotel database if (! @mysql_select_db('uniguest') ) { die( '<p>Unable to locate the Hotel List ' . 'database at this time.</p>' ); } $result = @mysql_query('SELECT DISTINCT state FROM hotelList ORDER by state'); if (!$result) { die('<p>Error performing query: ' . mysql_error() . '</p>'); } while ( $row = mysql_fetch_array($result) ) { echo(' | <a href="' . $_SERVER['PHP_SELF'] . '?stateSelect=' . $row['state'] . '">' . $row['state'] . '</a>'); } // Select the hotel database if (! @mysql_select_db('uniguest') ) { die( '<p>Unable to locate the Hotel List ' . 'database at this time.</p>' ); } if (isset($_GET['stateSelect'])) { $state2 = $_GET['stateSelect']; $query = mysql_query("SELECT * FROM hotelList WHERE state='$state2' ORDER by name") or die (mysql_error()); $name = $row['name']; echo($name); } else { echo('<p>Error: ' . mysql_error() . '</p>'); } ?>
$_SERVER[PHP_self]
can someone explain me with an easy example what the function for? I've read on the php.net,
$_SERVER['PHP_SELF'] On IIS
I'm testing some code on IIS. The form submission is not working on IIS but works fine on Apache. This is the form code: <form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> This is appearing in the browser address bar when submitting the form: http://192.168.10.89/multiple_select/%3C?=$_SERVER['PHP_SELF']?> On IIS a "HTTP 405 - Resource not allowed" error is returned because of the garbage in the adress bar.
$_SERVER['PHP_SELF'];
I try to have a simple login page. But The php and the html for the login page is the same file. So one small issue, is it executes like nothing was imputed therefore executing the message which indicates the person you have entered wrong data. My second major issue is that, when i press submit it does not do anything.
Make "blabla" Into Keywords As In "php.net/blabla"
I know this must be documented, but I cant seem to find it. How would you transform the URL into values? Like how php.net does; www.php.net/date does a search for "date" in their database... I have built a simple search function on my site, and I would like to do the same.. anyone who knows how? Or who has seen an article in the subject? Or has any other tips?
$_SERVER['PHP_SELF'] Question
I am attempting to use the below Select Form Element to allow users to change the category of data being viewed in a subsequent SQL statement. My problem is, from where I am at, what is my next step to be able to do an "if then else" loop based upon what is selected from this form element?
<?php Echo $_SERVER['PHP_SELF'];?> Question...
The statement: <?php echo $_SERVER['PHP_SELF'];?> would echo something like 'index.php' depending what your file is called, BUT is there a way to get it to echo the file and the VARs:
Why No [fragment] In Parse_url($_SERVER['PHP_SELF'])?
I'm trying to identify which named anchor is currently being viewed on a page. Although the address bar of my browser shows #whatever appended to the end of the url, I can't seem to find it in a variable. My efforts below return no value for ANYTHING except [path]. Am I missing something? $url = parse_url($_SERVER['PHP_SELF']); $scheme = ($url[scheme]); $host = ($url[host]); $port = ($url[port]); $user = ($url[user]); $pass = ($url[pass]); $path = ($url[path]); $anchor = ($url[fragment]); echo $scheme." = scheme<br>"; echo $host." = host<br>"; echo $port." = port<br>"; echo $user." = user<br>"; echo $pass." = pass<br>"; echo $path." = path<br>"; echo $anchor." = anchor<br>";
Problem Getting Script's URL ($_SERVER['PHP_SELF'] Not What I Expected)
I have a function that restricts access to a page to logged in users. When a user who isn't logged in goes to the page, it will dynamically generate a login form. I'm trying to use it in conjunction with the free shared SSL certificate offered by my host. To use SSL, you would change a URL like this http://mydomain.com/page.php to https://ssl.myhost.com/mydomain.com/page.php My problem: when my script dynamically generates the login form, it uses the $_SERVER['PHP_SELF'] value in the action field. But this ends up being '/page.php' rather than '/mydomain.com/page.php' so my form gets submitted to https://ssl.myhost.com/page.php instead of https://ssl.myhost.com/mydomain.com/page.php Simple I thought, I'll just use the SERVER or ENV variable that gives me the full url. My problem: it doesn't seem to exist!
|