Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

newuserphp

Members
  • Joined

  • Last visited

Everything posted by newuserphp

  1. This is on the parent-page : i f(isset($_POST['submit']) { $_SESSION['response'] = $_POST['selection']; And this is my code on the child-window : if (!(isset($_SESSION['login']) && $_SESSION['login'] != '') || (!isset($_SESSION['response']))) { header ("Location: www.example.com/access_denied.php"); exit() ; } Still not working The child-window is still accessible directly The "radio selection" is being made on the parent-page. But, the check needs to be performed on the child-window, doesnt it? Otherwise, the child-window will be accessible each time
  2. "....................does it post to itself to set $_SESSION['response']? Child Page - This will display information based on the selection from the first page?.............." Yes, this is the case. The parent-page posts to itself. When the SUBMIT button is clicked, then the child_window (new window) opens. Which is why I need a code which prevents access to this child_window directly
  3. Hello. I'm trying to include a small PHP code at the beginning of a certain file (which is a "new window"), which would prevent the user from directly accessing the file, if he inputs the URL directly into his browser. In other words : my website functions in such a way that, first the user has to make a radio-selection on the parent window, and click "submit", which opens a new "child" window. But, first the user has to be logged in! In order to prevent the window from opening, I wrote this code at the very beginning of the PHP file (for both parent and child windows) : <?php session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) { header ("Location: www.example.com/access_denied.php"); exit() ; If the user is not logged in, and he tries to go directly to a particular URL, he is re-directed to a file which displays an "ACCESS DENIED" text. However, for this particular situation (as explained above), the user first needs to make a selection on a parent page. If he does not choose anything on the parent-page, and simply enters the URL for the "child window" in his browser, he is still able to access the php file directly (which I do not want) The radio selection on the parent-page is as follows : if(isset($_POST['submit']) { $_SESSION['response'] = $_POST['selection']; On the child_window, I added the following code : if (!(isset($_SESSION['login']) && $_SESSION['login'] != '') || (isset($_SESSION['login']) && (!(isset($_POST['selection')))) { header ("Location: www.example.com/access_denied.php"); Meaning : even if the user is logged in..........unless he has made a selection on the parent-page, he cannot access the child-window. But, this code is not working. I even tried to create a random "$_SESSION" variable on the parent-page, which is activated once a radio-selection has been made.............and, on the child-window, I wrote a code, saying : if this random $_SESSION has not been set, the child-window would give an "access-denied" message. Still, this does not work. The user is still able to view and access the child-window by typing in the direct URL. Any help would be appreciated. Thanks
  4. Perhaps, it's my fault for not having stated my entire file-structure from the start I simply didn't think it was necessary, because, as I mentioned earlier : the second rule works perfectly. So, I assumed that the same format would work with the third rule. My file structure is as follows (from ROOT folder to file_name) : www.example.com/Principal/Rolan/file_name For the second rule, the file-structure is exactly the same. www.example.com/Principal/Project/file_name When I created the second rule (to hide the Project folder), I changed all my URLs in my php-code, to the following : /Principal/file_name And, it works. the "Project" folder is hidden from view So, naturally, when I wanted to do the same for "Rolan", I thought the same principle applies. But, I guess I was wrong. So............using the new HTACCESS code you just gave me : RewriteRule ^gagoo/([^/]+)/([^/]+)/?$ $1/$2.php [NC,L] I guess that : I should replace "gagoo" with "Rolan"..............and then change all my URL (in the php files) to : /Principal/file_name Am I on the right track ?
  5. I am still getting the 404 error Should I write the URL with our without "Rolan" ? /gagoo/file_name or /gagoo/Rolan/file_name ? I tried both; neither are working;
  6. Thanks, Nock. But, I'm still getting the error "404 : File not found" Am I using the correct URL in my code : /gagoo/Rolan/file_name ? (I also tried removing the "Rolan" from the URL : /gagoo/file_name. But it still does not work) I assume the "Rolan" should NOT be there (since, the purpose of the Rule is to hide the "Rolan" from the URL in the browser, the same way the first Rule hides the "PHP" folder from view)
  7. I created a Rule in my HTACCESS file, to hide a sub-folder. RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/?([^/]+)/([^/]+)/([^.]+)\.php [NC] RewriteRule ^ /%1/%3 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/?$ $1/Project/$2.php [NC,L] The first rule removes all file-extensions : php The second rule will hide the folder "Project" from the URL Both these rules are working perfectly. However, when I tried to add a third rule, to hide another folder, it failed. This second folder (Rolan) is in the same location as the "Project" folder, so I assumed that it should work simply by copy-pasting the second rule, and then adding a PREFIX to the beginning of the third rule : RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/?([^/]+)/([^/]+)/([^.]+)\.php [NC] RewriteRule ^ /%1/%3 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/?$ $1/Project/$2.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^gagoo/([^/]+)/([^/]+)/?$ $1/Rolan/$2.php [NC,L] I added the prefix "gagoo" to the third rule. Also, I removed the [NC,L] from the end of the second rule, and placed it at the end of the third rule. Then, in my PHP code, I wrote the URL as follows : www.example.com/gagoo/Rolan/file_name Both the first and second rules are still working. But, for the third rule, I am getting a "FILE NOT FOUND : 404" error. The thing is : I wrote a JavaScript code, which opens "file_name" in a "New Window". (Still, I doubt that this could be the reason for the problem)
  8. I created a Rule in my HTACCESS file, to hide a sub-folder. RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/?([^/]+)/([^/]+)/([^.]+)\.php [NC] RewriteRule ^ /%1/%3 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/?$ $1/Project/$2.php [NC,L] The first rule removes all file-extensions : php The second rule will hide the folder "Project" from the URL Both these rules are working perfectly. However, when I tried to add a third rule, to hide another folder, it failed. This second folder (Rolan) is in the same location as the "Project" folder, so I assumed that it should work simply by copy-pasting the second rule, and then adding a PREFIX to the beginning of the third rule : RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/?([^/]+)/([^/]+)/([^.]+)\.php [NC] RewriteRule ^ /%1/%3 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/?$ $1/Project/$2.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^gagoo/([^/]+)/([^/]+)/?$ $1/Rolan/$2.php [NC,L] I added the prefix "gagoo" to the third rule. Also, I removed the [NC,L] from the end of the second rule, and placed it at the end of the third rule. Then, in my PHP code, I wrote the URL as follows : www.example.com/gagoo/Rolan/file_name Both the first and second rules are still working. But, for the third rule, I am getting a "FILE NOT FOUND : 404" error The thing is : I wrote a JavaScript code, which opens "file_name" in a "New Window". (Still, I doubt that this could be the reason for the problem)
  9. This is 2015 ???????????? REALLY ????? Damn, time sure flies when you got work to do
  10. Quick question : if I had a file-path that looked like this : www.example.com/CODE/myfile.php www.example.com/CODE/HTML/myfile.html Basically, I want to hide everything that comes AFTER "Code". Like so : www.example.com/CODE/..................... How can I add it to my HTACCESS file ? My file already looks like this : Options -Indexes Options -MultiViews Options +FollowSymlinks <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> From the links you gave me, I'm guessing I need to add something like this : RewriteEngine On RewriteRule ^/pages/(.+)\.php $1\.php [NC, L]
  11. Now, THAT'S more like it It shows the whole window now But, with a scroll bar..............maybe, I should set the "scrolling" back to "no"
  12. Still, this does not solve my issue Removing the Height and Width parameters only made it worse : the window shrank even further, to the size of a cell phone And, styling the width and height in CSS did not change anything : <!doctype html> <html> <head> <title>MY IFRAME TEST</title> <style type="text/css"> body { margin: 0; } iframe { width:100%; height:100%; } </style> </head> <body> <iframe src="mytest.html"> </iframe> </body> </html>
  13. Thanks for the response, Nillerversion. Regarding the closing tag..........that was just a typo on my part. It was not part of my code. (My original code is exactly as you wrote it). As regards the bad effects of iFrame..........yes, I'm aware of them. Aside from the one you mentioned, regarding SEO, iFrames also : (a) prevent users from Bookmarking specific pages on one's website; ( b ) cause difficulties with Debugging, Of course, I would much rather have used the HTACCESS file. But, the "Rewrite" command in htaccess does not hide folders or filenames. It simply re-directs from one page to another. Meaning : the "target" page has to exist anyway.
  14. There is nothing missing
  15. I am trying to use the iFrame tag to hide my folder and file-names in my URL. I've found the correct syntax from online tutorials. However, when I execute it, for some reason, the window which is displayed is severely "restricted" The Height and Width are restricted to only about a fifth of the entire screen. Here is the code for my INDEX.HTML file : <!DOCTYPE HTML> <html> <head> <title>My Title</title> </head> <body> <iframe src="mytest.html" height="100%" width="100%" name="Your Title" /> </iframe> </body> </html> Index.html is, of course, the default webpage for my website. So, when it's executed, the browser goes to : MYTEST.HTML I thought that setting the HEIGHT and WIDTH to 100% was supposed to take care of this issue. But, it didn't. So, I decided to add some CSS styling, as follows : <!DOCTYPE HTML> <html> <head> <title>Your Title</title> <style type="text/css"> <!-- Full Screen Page Fix --> body { margin: 0; } </style> </head> <body> <iframe src="mytest.html" height="100%" width="100%" name="Your Title" /> </iframe> </body> </html> I also added the attributes : frameborder="0" scrolling="no" And, then, I changed to : frameborder="0" scrolling="yes" But, this still did not resolve the issue. Is the problem with my browser itself? Although, I doubt it.........seeing as I've tested this with Chrome, Mozilla, and IE
  16. Hi. I have created a password reset function in PHP. It's working just fine...........except that, for some reason, I'm unable to set the recipient's email address : "TO" The code works this way : (a) the user is asked to provide his login/username ( php sends an sql query to the database; © if the username is found, php takes the email-address, and sends a Reset Link via email (d) this reset-link has a unique "token" attached to it (e) the user clicks on the link in his email, and is re-directed to a new page where he resets his password Everything is working fine...........except for the email structure itself. The email comprises : TO, CC, SUBJECT, BODY, and HEADERS. Everything is being shown..........except the actual "TO". In fact, the only reason I know that the code works ie because I'm getting a copy of the email, via the the "CC" Here is my code : if(isset($_POST['submit']) || isset($_POST['submit'])) { $login = $_POST['login']; $query = "select * from personal_data where login='$login'"; $result = mysqli_query($conn,$query); $count=mysqli_num_rows($result); $rows=mysqli_fetch_array($result); if($count==0) { echo "Sorry; that username does not exist in our database"; } else { function getRandomString($length) { $validCharacters = "ABCDEFGHIJKLMNPQRSTUXYVWZ123456789!#+=%&/?*$"; $validCharNumber = strlen($validCharacters); $result = ""; for ($i = 0; $i < $length; $i++) { $index = mt_rand(0, $validCharNumber - 1); $result .= $validCharacters[$index]; } return $result; } $token=getRandomString(40); $q="insert into token (token,login) values ('".$token."','".$login."')"; mysqli_query($conn,$q); function mailresetlink($to,$token){ $to = $rows['email']; $subject = "Password Reset"; $uri = 'http://'.$_SERVER['HTTP_HOST'] ; $message = ' <html> <head> <title>Password Reset Link</title> </head> <body> <p>We received a Password-Reset request from your account.</p> <p>Click on the following link to reset your password : <a href="'.$uri.'/PHP/password_reset?token='.$token.'">Reset Password</a></p> </body> </html> '; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: Support<support@xxxxx.com>' . "\r\n"; $headers .= 'Bcc: Info<info@xxxxx.com>' . "\r\n"; if(mail($to, $subject, $message, $headers)) { echo "A password reset link has been sent to your email address." } } if(isset($_POST['login'])) { mailresetlink($email,$token); exit(); } } }
  17. Not yet ready to publicize it. Still working on the Social Media links. Once those are ready, then my site goes live And, still a few loose ends to tie up...........unfortunately. Like configuration issues (I posted a few here on this forum)
  18. Well, basically what I wrote earlier : Should I declare a condition (COND) before every single RULE ? Like this : RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.php [NC,L] Or...........should I declare the conditions only ONCE..........and then right all the rules below it : [RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteRule ^([^/]+)/$ $1.php [NC,L] RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php I have examined every available online tutorial, and it does not address this point anywhere.
  19. I am still searching for tutorials regarding the proper syntax I should use I don't suppose you could help me out with a few tips?
  20. Oops! That EMOTICON was supposed to be a <smiley face>
  21. I finally got it working (a very BIG THANKS to you, rallport .gif' alt=':seas8:'> ) I simply commented out EVERY other line from the code, and left only this : # BEGIN WordPress <IfModule mod_rewrite.c> # disable directory browsing Options -Indexes # enable Multiviews Options -MultiViews # allow server to process and follow all "fictional" URLs. Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php #RewriteEngine On #RewriteBase / #RewriteRule ^index\.php$ - [L] #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule . /index.php [L] #RewriteCond %{REQUEST_FILENAME} !-f #RewriteRule ^([^/]+)/$ $1.php [NC,L] #RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php </IfModule> # END WordPress For the world of me, I cannot figure out exactly WHAT was bothering the code in the first place. Obviously, htaccess can accept hundreds of lines of code. But, how to layer them, in the proper order ? Because, by process of elimination (that is, by commenting out each line separately), I can conclude that my code-syntax was wrong! But, why exactly? Should I declare a condition (COND) before every single RULE ? Like this : RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.php [NC,L] Or...........should I declare the conditions only ONCE..........and then right all the rules below it : [RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteRule ^([^/]+)/$ $1.php [NC,L] RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php I have examined every available online tutorial, and it does not address this point anywhere.
  22. I was thinking : is it possible that my code-structure is wrong? For example : these lines...... Options -Indexes Options -MultiViews Options +FollowSymlinks Should they be INSIDE the module? Meaning, should they come before or AFTER the : <IfModule mod_rewrite.c> RewriteEngine On
  23. (a) No, there are no htaccess files anywhere. I had to create this one myself, and import it into my PUBLIC_HTML (WWW) folder ( b ) The file has permission : 755 (It was 644 at first, but I thought this might be the cause of the problem. So I changed it to 755. But, this did not help)

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.