PHP - How To Do Redir.php?page=http://****.com
I have tried to make a redirect like this: redir.php?page=http://****.com
Code: [Select] <?php if(is_file($_GET['page'])){$page = $_GET['page'];} else{$page = "DEFAULT.php";} header("Location: ".$page); ?> But I only get: Quote Forbidden You don't have permission to access /redir.php on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. What should I do? Could it have something to do with encoding of special characters? Ordinary php scripts like Code: [Select] <?php echo "Hello"; ?> Works fine. Similar TutorialsTrying to run a simple program that, when submitted, stores the username and password as cookies. When clicking Submit, I get the error "HTTP Error 405 - The HTTP verb used to access this page is not allowed". If the username and password fields are left blank when submitting it's suppose to give a message to enter a username and password, but, I still get that error message. HTML form: Code: [Select] <!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" xml:lang="en" lang="en"> <head> <title>Week 1 Project--Cookies</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <form action="cookie1.php" method="post"> <h2 align="center">Cookies</h2> <br /> <div> <p>Enter your username and password and click "Submit":</p><br /> <p>Username:<input type="text" name="username" size="20"></p> <p>Password:<input type="text" name="password" size="20"></p> </div> <br /> <div><input type="submit" name="submit" value="Submit" /></div> <br /> <div> <input type="reset" name="Reset" value="Start Over" /> </div> </form> </body> </html> PHP file: Code: [Select] <!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" xml:lang="en" lang="en"> <head> <title>Cookie File</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <div> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { setcookie('username', $_POST['username'], time() + 2592000); setcookie('password', $_POST['password'], time() + 2592000); } if(($_POST['username'] == "") || ($_POST['password'] == "")) { print "You must enter both a username and password. Press the Back button on your browser and try again."; } else if (isset($_COOKIE['username'])) { print "Welcome, " .$_COOKIE['username']; } ?> </div> </body> </html> Hi there, Any help is greatly appreciated. I've commented out the code giving me trouble. Error = <br /> <b>Warning</b>: curl_setopt(): supplied argument is not a valid cURL handle resource in <b>/###.php</b> on line <b>34</b><br /> <br /> <b>Warning</b>: curl_setopt(): supplied argument is not a valid cURL handle resource in <b>/###.php</b> on line <b>35</b><br /> <?php $ch = curl_init(); $timeout = 30; $userAgent = $_SERVER['HTTP_USER_AGENT']; if ($_REQUEST['update']) { curl_setopt($ch, CURLOPT_URL, $_REQUEST['url']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_USERPWD, $_REQUEST['username'] . ':' . $_REQUEST['password']); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); //curl_setopt($c, CURLOPT_POST, true); //curl_setopt($c, CURLOPT_POSTFIELDS, $_REQUEST['update']); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); $response = curl_exec($ch); if (curl_errno($ch)) { echo curl_error($ch); } else { curl_close($ch); echo $response; } } How do I only redirect the page when index.php is present? Hi, I don't know very much about php. I don't know any at all, actually. I play a game called Roblox where you get to use the programming languange, "Lua" to script your own games. What I am requesting has been done before on this game, but I only know Lua. I was also told PHP cURL is needed. Anyways, let me get to the point. I am essentially trying to create a system on my webserver (You can send HTTP Requests to external sites in this game via script) that will essentially log into an account on Roblox, to perform a task. My current idea would be to have the Lua script send a request to my webserver with an generated code that would access the username and password of my roblox account (Which would be on the webserver). It would then perform a task. Is this a good way to go about this? If not, I am open to suggestions. If you can find the time to actually help me set this up on my webserver, I would greatly appreciate it! I'm also sorry if this is the wrong place for this post, I'm new here. Hi. I am trying to extract the main url from a string.
For example.
I want to extract:
"http://google.com" from "http://google.com/search/pic.jpg"
"https://secure.co.uk" from "https://secure.co.uk/secure/secure.gif"
I am able to do this with this code, where $url is the url:
preg_match("http://(.*?)/", $url, $matches);
preg_match("https://(.*?)/", $url, $matches);
Is there away to consolidate this into one regex search? Or am I being picky?
Thanks!
I am learning PHP using the book "Beginning PHP and MySQL 5 - From Novice to Professional", and I have come across a lesson in the book which I am stuck on. The lesson is on using the echo() statement. I've typed in the following code and saved it as a php file.... <?php $heavyweight = "Lennox Lewis"; $lightweight = "Floyd Mayweather"; echo &heavyweight, " and ", $lightweight, " are great fighters."; ?> My Apache and PHP is working fine as my other PHP files work properly. When I try and view the file it says... "The website encountered an error while retrieving http://localhost:8888/phpdocs/multiplestringsecho.php. It may be down for maintenance or configured incorrectly." and when I click on more information it says... "HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request." Any ideas? Have I done something wrong? Any help would be much appreciated. Hi All, I know it is a silly error but I am very new to PHP (only 2 days!!!) & unable to resolve this. I have seen a lot of resolutions online for example: 1) Copying the "php5isapi.dll" file to the PHP directory & under "Program Files" as well. 2) Copying the "favicon.ico" file etc etc Before I could elaborate the issue, please note that I am a Windows user - Windows XP (I know its not the best of the OS's to work with!!!) When initially I started getting the issue, I checked the "error.log" file under "C:\Program Files\Apache Software Foundation\Apache2.2\logs" & following is what I saw: ----------------------- [Sun Sep 18 14:13:25 2011] [notice] Server built: Sep 9 2011 10:26:10 [Sun Sep 18 14:13:25 2011] [notice] Parent: Created child process 4420 [Sun Sep 18 14:13:25 2011] [notice] Child 4420: Child process is running [Sun Sep 18 14:13:25 2011] [notice] Child 4420: Acquired the start mutex. [Sun Sep 18 14:13:25 2011] [notice] Child 4420: Starting 64 worker threads. [Sun Sep 18 14:13:25 2011] [notice] Child 4420: Starting thread to listen on port 80. [Sun Sep 18 14:14:55 2011] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico [Sun Sep 18 14:21:37 2011] [notice] Server built: Sep 9 2011 10:26:10 [Sun Sep 18 14:21:37 2011] [notice] Parent: Created child process 7976 [Sun Sep 18 14:21:37 2011] [notice] Child 7976: Child process is running [Sun Sep 18 14:21:38 2011] [notice] Child 7976: Acquired the start mutex. [Sun Sep 18 14:21:38 2011] [notice] Child 4420: Released the start mutex [Sun Sep 18 14:21:38 2011] [notice] Child 7976: Starting 64 worker threads. [Sun Sep 18 14:21:39 2011] [notice] Child 4420: All worker threads have exited. [Sun Sep 18 14:21:39 2011] [notice] Child 4420: Child process is exiting [Sun Sep 18 14:21:39 2011] [notice] Child 7976: Starting thread to listen on port 80. [Sun Sep 18 14:21:52 2011] [error] [client 127.0.0.1] File does not exist: C:/Rahul/Personal/Web Development/favicon.ico ---------------------- Then I created an icon file and named it "favicon.ico" & placed it in the following destinations: 1) C:/Rahul/Personal/Web Development/ and 2) C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/ but to no avail But interestingly & surprisingly, the error.log file stopped giving any of the above error messages but I still get the HTTP Error. Following is the error message that I get on the browser: -------------------------- Server error The website encountered an error while retrieving http://localhost/Forms/insert%20data.php. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this webpage later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. -------------------------- Now, just to let you know which php I am using, so, just to let you know, I just copied the html & php from http://www.w3schools.com/PHP/php_mysql_insert.asp. Following are they: HTML: ---------------------------- <html> <body> <form action="insert data.php" method="post"> Firstname: <input type="text" name="firstname" /> Lastname: <input type="text" name="lastname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body> </html> ----------------------------- PHP ----------------------------- <?php $con = mysql_connect("localhost","root","orange"); if (!$con) { die('Could not connect: ' . mysql_error()); } echo "Connection established"; mysql_select_db("my_db", $con); $sql="INSERT INTO Persons (FirstName, LastName, Age) VALUES ('$_POST['firstname']','$_POST['lastname']','$_POST['age']')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added with name: " $_POST[firstname] $_POST[lastname]; mysql_close($con) ?> ------------------------- I hope someone is able to help me in this & I guess I have mentioned everything I could to explain the error! Many thanks in advance! Rahul i have been searching for a solution for about a day already. can anyone help me on how to use the http functions (if thats what it is called) in php? http://www.php.net/manual/en/book.http.php like for example. i need to use the http_get() function but it returns Fatal error: Call to undefined function.. in the manual it says that i need to put php_http.dll on the ext dir and enable it in php ini like this.. extension=php_http.dll ..which i already did im working under.. windows xp sp3 php 5.3.1 thanks guys I am trying to build an app which will scan a site multple times, the only problem is the 403 error, how do I get around this. Searching seems to imply curl or user_agent, but can't get it working. Any suggestions? Thanks Just a quick question. I'm using the Live HTTP Headers add-on for Firefox that display all the HTTP headers etc. I'm writing an article on it and want to include a screenshot of it in action. Are there any headers that I should hide from the reader for security reasons? Thanks for any help. when i upload this code and refresh the page nothing shows up the only thing htat shows up is HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. please helop Code: [Select] <?php $title = "Home"; ?> <?php require("styles/top.php"); ?> <?php if ($username){ echo "<table> </div></td> </tr> <tr> <td width="244" valign="top"><br /> <form id="form1" name="form1" method="post" action="search_results.php" style="margin-left:20px;"> <input name="var" type="text" class="size12" id="var" style="width:124px; background-color: #A4D1FF;" /> <input name="button" type="submit" class="size11" id="button" value="Search" /> </form> <br /> <div id="leftNav" style="margin-left:22px;"> <!-- Start tv --> <strong><font color="#FFFFFF"><span class="size16">TV</span></font></strong><br /> <a href="tv.php?c=tv&sc=cartoons">Cartoons <font size="-3" color="#FFFFFF"></font></a><br /><a href="tv.php?c=tv&sc=news">News <font size="-3" color="#FFFFFF"></font></a><br /><a href="tv.php?c=tv&sc=adventures">Adventures <font size="-3" color="#FFFFFF"></font></a><br /><a href="tv.php?c=tv&sc=horror">Horror<font size="-3" color="#FFFFFF"></font></a><br /><a href="tv.php?c=tv&sc=Drama">Drama<font size="-3" color="#FFFFFF"></font></a><br><br /> //End TV --> // Start Videos --> <strong><font color="#FFFFFF"><span class="size16">Videos</span></font></strong><br /> <a href="videos.php?c=videoss&sc=children">Children <font size="-3" color="#FFFFFF"></font></a><br /><a href="videos.php?c=videos&sc=music">Music<font size="-3" color="#FFFFFF"></font></a><br /><a href="videos.php?c=videos&sc=comedy">Comedy<font size="-3" color="#FFFFFF"></font></a><br /><a href="videos.php?c=videos&sc=youtubemovies">Youtube Movies <font size="-3" color="#FFFFFF"></font></a><br /><a href="videos.php?c=videos&sc=sports">Sports <font size="-3" color="#FFFFFF"></font></a><br /> <br> <!-- End videos--> <!-- Start Movies --> <strong><font color="#FFFFFF"><span class="size16">Movies</span></font></strong><br /> <a href="movies.php?c=movies&sc=comedy">Comedy <font size="-3" color="#FFFFFF"></font></a><br /> <a href="movies.php?c=movies&sc=action">Action <font size="-3" color="#FFFFFF"></font></a><br /><a href="movies.php?c=movies&sc=adventure">Adventures <font size="-3" color="#FFFFFF"></font></a> <a href="movies.php?c=movies&sc=horror">horror <font size="-3" color="#FFFFFF"></font></a><br /> <a href="movies.php?c=movies&sc=drama">Drama<font size="-3" color="#FFFFFF"></font></a><br /><br /> <br /> //End Movies </div> </table>"; } else echo "<h2><font color='red'>You must be logged view this Part.</font></h2>"; ?> <?php require("styles/bottom.php"); ?> Not sure if this is possible. What I am trying to do is remove a section of text a user posts. ie: go to this url: http://url.com or http://this.domain.org I already have it to strip they <a href="whatever but not sure if I can do the other. Any help would be appreciated. Thanks I have a hardware device that I can send commands to by typing in a URL in the address bar. One command tells me if the ports are in use: Code: [Select] http://admin:12345678@192.168.1.10/Set.cmd?CMD=GetPower It returns the result: Code: [Select] p61=1,p62=1,p63=1,p64=1 What I want to do is try and grab the result with PHP when the page loads so I can tell people if the port is turned on or off. So "p61=1" means port 1 is turned ON. If "p61=0" was displayed, it means port 1 is turned OFF. I am not sure if it is even possible to grab the information using PHP or not. Any place to start would be great! Thanks! It seems to me that this should be easy, but I can't find it in the manual or the on the web, and the values in $_SERVER don't suggest anything. Context: script A loads script B using HTTPS. Now script B has to load resources (images, style sheets, etc). Browsers often object to HTTP references from a script run by an HTTPS request, so script B should generate URLs that use HTTPS. Thus it has to know that it was loaded with HTTPS. I can do this by brute force if I have to (defining a "protocol" constant in the script itself), but I'd rather make the test automatic. Hi Guys,
Total PHP Noob here. I’ve run into a brick-wall and would appreciate some words of wisdom. I can do this with a browser: http://86.60.161.24 // will echo hello World I can’t do this with my server: <?php $url = 'http://86.60.161.24'; $contents = file_get_contents($url); echo ($contents); ?> It looks like the server-side HTTP -request never “touches” my Arduino-chip. No network activity detected. Obviously there is going to be a lot more data transfer happening but I need to solve this issue first. Is there anything I can do to make this work? Any and all input greatly appreciated. Cheers!!
Hi guys.. i am not very sure where to post about this issue but im giving a try and hope to get some ideeas where this might come maybe. So i have a small website with a members database.. the website itself it has SSL and works properly on a https connection. The problem comes when a member tries to access via http. Unfortunetaly on a page i have to keep it http due to some ads that i display there and dont work on https. If a member logs in and surfs the website via https everything is working perfectly.. but when he changes and tries to access via http he automatically gets logged out.. if he tries to login via http he also cant and gets an error with an invalid token. So basically i think my database cant connect when accessed by http.. Any of you ever encountered this issue ? Or maybe have some ideeas where this issue is coming from ?
Thanks and any ideea or help very appreciated Hi i followed a tutorial to create a register, login, members list and member profile pages but when i register, login and go to members list, the page its blank, i viewed the source code for the members page and its clearly trying to show something but i dont know what to do? Can any body help me please. Hello! I'm trying to understand exactly how http requests relate to a php script. 1) What would be considered a large amount? 2) How can I see how many I have for a given page? Thank you, Eric Hi, Anyone can help me on how to receive a file as a http upload? I have an application that sends an xml file with http (post method) to our server and I need to make a script that receives that, writes it to database and archives the file away. Tried to google something but no luck so far. If anyone have done something like this I appreciate any help you can give. Thanks. |