PHP - Why Am I Seeing Php When I View The Source Code Of The Page?
Hello all,
i have a feeling im doing something wrong, but i have no idea what. being server-side code, php should not show when you 'view page source' in your browser (or rather it should display as html), correct ? why, then am i seeing php code when i view page source? see attached image Similar Tutorialslooking for a way to view the PHP source code of any PHP page on the web. Looking for a way to obtain PHP source code in order to help me with a certain issue. Advise. when i right click to view page source i just saw the javascript calling php as source file , while on page there is table, i need to read that table in database , is there nay way to do that, file_get contents dont work on it its just take javascript not the page table I've got another funny one... I've noticed that sometimes on some of my pages (all of which are generated by PHP), when i click view source, the source it shows me is not from the page i'm looking at. This isn't a problem that affects me in any way (not yet anyway), it's just a bit odd. I've noticed it happens a little more often in chrome than any other browser. Has anyone else noticed anything like this before? I'm intrigued to know the cause. The only real google response was this: http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg144609.html and i haven't seen another issue similar on here. by any means is there a way to view a email.php form source? not just the html part but the entire script including the php? well basically im trying to do that the 'subject says. ive done my homework and had around 10 examples of using curl, but none of them worked in my case. this is the final code i'm using <?php $cookiefile = '/temp/cookies.txt'; #2 ways ive tried doing #$data = array('edit[username]' => 'REMOVED', 'edit[password]' => 'REMOVED', 'edit[submit]' => 'Login'); $data = array('username] => 'REMOVED', 'password' => 'REMOVED', 'submit' => 'Login'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://pokerrpg.com'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_exec($ch); curl_setopt($ch, CURLOPT_URL, 'http://pokerrpg.com/furniture_store.php'); $contents = curl_exec($ch); $headers = curl_getinfo($ch); echo $contents; curl_close($ch); unlink($cookiefile); ?> im not sure about the cookie file, but i just made a txt file to that location. and empty txt file. hope it's fine. the page i'm trying is http://pokerrpg.com, you can even look the source code that both of these fields do exist. when i run it, the output is a login page without logging in, so it does not log in. Hey everyone, So here is my problem. I have some code to display the amount of views that page has got. In this case it is the thread in my forums section. I have used the same code to show how many people have views a certain persons profile page and that works fine but when I use it on my forum thread page I get this error. Quote You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='20' LIMIT 1' at line 1 Here is the section of code: Code: [Select] <?php $thread_id = preg_replace('#[^0-9]#i', '', $_GET['id']); $getThreadViews = mysql_query("SELECT view_count FROM forum_posts WHERE id='$thread_id' LIMIT 1") or die (mysql_error()); $row = mysql_fetch_assoc($getThreadViews); $counter = $row['view_count']; if($counter == 0){ $counter = 1; $startCounter = mysql_query("INSERT INTO forum_posts (view_count) VALUES ('$counter') WHERE id='$thread_id' LIMIT 1") or die (mysql_error()); } $threadViews = $counter+1; $appendCounter = mysql_query("UPDATE forum_posts SET view_count='$view_count' WHERE id='$thread_id'") or die (mysql_error()); ?> I have checked that there are no spelling errors so just wanted to show it to a fresh pair of eyes because its really starting to annoy me. Thanks in advance for any help. I have a strange problem. When a guest visits my contact-user.php page, they get a message telling them the must login before viewing the page. After the guest logs in, they view the same page and it tells them they have to login again (keeps on looping). But if they manually refresh that page with the "you must be logged in" message, it recognizes the login and lets them in. How can I get this page to immediately recognize that the user is logged in and not require them to refresh the page manually? Here is my code for contact-user.php <?php session_start(); header("Cache-Control: private, max-age=10800, pre-check=10800"); header("Pragma: private"); header("Expires: " . date(DATE_RFC822,strtotime("+2 day"))); include("connection.php"); mysql_select_db("database"); if (isset($_SESSION['username'])) { ******** MY HTML PAGE CONTENT ******** } else { echo "<meta http-equiv='REFRESH' content='2;url=http://www.mysite.com/login.php'> <center><font color='#EE0000'><p>You must be logged in before negotiating. You will now be redirect to the login page.</p></font></center>"; } ?> Here is my code for login.php script: <?php include("connection.php"); mysql_select_db("database"); session_start(); if(isset($_POST['login'])){ $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $tUnixTime = time(); $sGMTMySqlString = gmdate("Y-m-d H:i:s", $tUnixTime); if (!$username || !$password) { print "Please fill out all fields."; exit; } $logres = mysql_num_rows(mysql_query("SELECT * FROM members WHERE username = '$username' and password = '$password'")); if ($logres <= 0) { print "Login failed. If you have not already, please signup. Otherwise, check your spelling and login again."; exit; } else { $_SESSION['username'] = $username; if (isset($_SESSION)) { echo'You are now logging in'; mysql_query("UPDATE members SET activity = '$sGMTMySqlString' WHERE username = '$username'"); } else { echo "You are not logged in!"; } echo'<html><head><meta http-equiv="REFRESH" content="1;url=http://www.mysite.com/members/' . $_SESSION['username'] . '/"></head><body></body></html>'; exit; } } ?> Is there any way using only PHP? The problem is that I don't have access to the form processor, or to MySQL. Advance thank you. Can you help please. The error..... Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in C:\wamp\www\test_dabase.php on line 24 code. Code: [Select] <?php //database connection. $DB = mysql_connect("localhost","root") or die(mysql_error()); if($DB){ //database name. $DB_NAME="mysql"; //select database and name. $CON=mysql_select_db($DB_NAME,$DB)or die(mysql_error()."\nPlease change database name"); // if connection. }if($CON){ //show tables. $mysql_show="SHOW TABLES"; //select show and show. $mysql_select2="mysql_query(".$mysql_show.") or die(mysql_error())"; } //if allowed to show. if($mysql_select2){ //while it and while($data=mysql_fetch_assoc($mysql_select2)){ //show it. echo $data; } } ?> So I am completely done with my forum after several posts here and a lot of time. But crap! I just realized that the way my avatar system works it will give away the password! I REALLY don't want to redo that system because truth is it is about 40 percent of the entire sites coding. It works by making pictures in a directory named the usersname.thepassword . Whatever filesystem. Now when I echo the path everyone can see the password and username in the source code! And thy can click it to see the picture! Is there a way to hide the paths or the source codeM thanks! Does any one have a better idea to protect PHP files so that you can distribute a 'release' without the customer being able to read the source files. There are tools on the internet which costs money, BUT your are dependant on their software and if its not open source, its not trustworthy. What I've done so far is writing an ISAPI DLL in borland cpp and installed it under iis6. Basically you call this isappi dll and it decrypts the encrypted php files and executes them respectively. It is thread safe (as is php). There are other methods available on the net that you use to encrypt your pages, BUT the decryption algorithm is found in your main php file and duh, if you can read the main file, you can easily decrypt all other files, so that is a bad idea. Any other ideas? Possibly to write a PHP extension perhaps but I have not been able to get that working on borland cpp. So I am completely done with my forum after several posts here and a lot of time. But crap! I just realized that the way my avatar system works it will give away the password! I REALLY don't want to redo that system because truth is it is about 40 percent of the entire sites coding. It works by making pictures in a directory named the usersname.thepassword . Whatever filesystem. Now when I echo the path everyone can see the password and username in the source code! And thy can click it to see the picture! Is there a way to hide the paths or the source codeM thanks!
How to edit my source code so the output prints correctly ?
Currently testing a site thats almost built, am going to be including php on a sidebar on all pages so thought it'd be easier to just make all pages .php, however when i upload and try and view, in Firefox it just displays the source code on screen! It does it on other computers, but works fine in IE! ARRGGGHH Anyone have a clue? Kind Regards, Chris I've been developing a php application that runs my entire company for the last 4 years. One of the things I never thought of until now is that the server guys or anyone else could copy the source code and db and be able to start up another company which brings up my question to you.... How would you protect your application? My thought is to create one small php file that is encrypted with something that is required to make the entire site run (not sure at this point what it would be that they couldn't just rebuild). Then if this file sees it's on a different domain/ip it requests data from my site which logs the info for me to look at. If I find out it's something not approved, it would then not allow the program to run and will give a error. What is your idea? Ok this has been driving me absolutely crazy. I have a script that gets called by Prototype's Ajax.Updater() class which should then update a div. It does update the div but a portion of what gets outputted doesn't render. Code: [Select] if (is_array($PROCESSED["associated_proxy_ids"]) && count($PROCESSED["associated_proxy_ids"])) { foreach ($PROCESSED["associated_proxy_ids"] as $student) { if ((array_key_exists($student, $STUDENT_LIST)) && is_array($STUDENT_LIST[$student])) { ?> <li class="user" id="audience_student_<?php echo $STUDENT_LIST[$student]["proxy_id"]; ?>" style="cursor: move;"><?php echo $STUDENT_LIST[$student]["fullname"]; ?><img src="<?php echo ENTRADA_URL; ?>/images/action-delete.gif" onclick="removeAudience('student_<?php echo $STUDENT_LIST[$student]["proxy_id"]; ?>', 'students');" class="list-cancel-image" /></li> <?php } } } I've echoed from within the foreach and the following if and the $student variable does have a value, however I'll point out that it also doesn't render but that may be because its not a <li>, I'm not sure. Now, if I take that li element lin end output it outside of the foreach loop it renders just fine(once I substitute the $student variable for a known index of course). Inside the loop it doesn't. I can see it in the source code of the page but for some reason its not rendering. I'll put the output from the source of the page below, the top is the code output from within the loop and the bottom is from outside of the loop. The bottom renders as expected, the top doesn't. Code: [Select] <!--foreach li element:doesn't render--> <li class="user" id="audience_student_2" style="cursor: move;">Hudson, Tom<img src="http://localhost/entrada/www-root/images/action-delete.gif" onclick="removeAudience('student_2', 'students');" class="list-cancel-image" /></li> <!--non foreach li element:renders--> <li class="user" id="audience_student_2" style="cursor: move;">Hudson, Tom<img src="http://localhost/entrada/www-root/images/action-delete.gif" onclick="removeAudience('student_2', 'students');" class="list-cancel-image" /></li> They're identical. I can't figure out for the life of me why this isn't working. Any help would be great. Hi, I need to extract the integers from the source code:
<span class=CatLevel1><a onclick="Javascript:ShowMeu('21');">Arts</a> (9768)</span> <span class=CatLevel1><a onclick="Javascript:ShowMeu('271');">Industrial Products</a> (9321)</span> <span class=CatLevel1><a onclick="Javascript:ShowMeu('1273');">Baby</a> (11407)</span>What are the pattern that I can use to retrieve all the integer in the bracket (9768, 9321, 11407)? This is my php code: <!DOCTYPE html> <html> <body> <?php $file_string = file_get_contents('http://www.lelong.com.my/'); preg_match('/<title>(.*)<\/title>/i', $file_string, $title); //pattern $title_out = $title[1]; echo $title_out; ?> </body> </html>Thanks Edited by Raex, 22 August 2014 - 12:49 AM. Hi, I'm looking for a code to view the date of the past weekdays. Forexample, if it's thursday, I want it to view the dates for wednesday, tuesday, monday, Friday before. Thank you in advance. This is source of a page: http://vn-ace.com/forum/test.txt I want to get contents betweent <blockquote class="postcontent restore">() and </blockquote>() but i dont know how to do ? How can i do ? Please help me. I am newbie. Thanks Hey guys, First post here, so feel free to flame me if im violating the rules somehow. So, the issue is this: i built an ebay listing creator for a customer. it conssists of a form with several fields being posted to a page that assembles everything into a listing (text, images, radio buttons etc.). now, what i want to do is to easily allow the customer to copy the compiled source code into the clipboard (or a txt file, doesnt really matters) - in order to easily copy it into ebay. I tried it with CURL, but all i get is the source without the posted information. I must be missing something there. Any help would be appreciated, if you need links or codes iv's used, ill provide. Thanks in advance! |