• 0

Newbie here in PHP and need help for this!


Question

Ok.. im doing a kind of registration form for users... so i can deleted user from another page as an admin.. now for example i want to delete a user and i have this link:

href=deleteuser.php?userid=X

where the x depends of the user i want to delete

so in the deleteuser.php file i have a routine or function that delete the user...for example

DELETE FROM TABLE WHERE field=userid...

It works great... my problem or the thing i wanna know is HOW TO PREVENT DELETING DIRECTLY FROM ADDRESS BAR??

for example if i write in the IE address bar this http://server/deleteuser.php?userid=5 it will execute directly the script...

so i want the script only for being executed if the admin or the user that wants to delete the record comes from the page where you choose the user he wants to delete...

I dont know if you get my question.. i would like your help please!

Any question yo ucan tell me!

Thanks!

14 answers to this question

Recommended Posts

  • 0

Hi there,

There are several ways this can be done..

1) Make the delete page check the referrer page URL, so it has to be referred from the page where you have the click link...

2) Write a password authorization script and make it so you have to type a password in before it works, or have it check for a cookie which you can make it place when you login as admin on the page where you have the link.

3) Place the deleteuser.php into a folder and place a htaccess file inside the folder and make it password protected.

Hope that helps!

  • 0

Here's the code.. I don't know if doing it this way is 100% secure though, anyone know if its possible to forge refer info? It might be, not sure tho..anywho, it will keep most users out unless they are determined...

Stick this at the very top:



<?php

if (!strstr($HTTP_REFERER, "Whatever the url of the page is goes here"))

{

print "Go away.";

exit;

}

?>

[/PHP]

That should work...

X.

  • 0

Hi sunshock,

I learned without any books, so I wouldn't know of any good ones.. but the way I learned was by reading the php manual at http://www.php.net/

It's free, and if you already know a bit of programming, it shouldn't be that hard.

Hope that helps,

Xcalibur

  • 0

Another question but a little diferent..

i have some data in my db, so im looking for a function or anything i can read about this... i want to retrieve my data from the database and put it on a table but if i have 100 rrecords i dont want to show them all i would like to have something like search results in yahoo, google, etc etc etc.. that you only show 10 results and if you hit back or next links you go to the next 10 records ..

Thanks!

  • 0
Originally posted by Nxt_Gate

Another question but a little diferent..

i have some data in my db, so im looking for a function or anything i can read about this... i want to retrieve my data from the database and put it on a table but if i have 100 rrecords i dont want to show them all i would like to have something like search results in yahoo, google, etc etc etc.. that you only show 10 results and if you hit back or next links you go to the next 10 records ..

Thanks!

Well that script is pretty complicated for a newbie :p It'll take time for you to do ...

All i have to contribute is about the searching: Remember that % is the wildcard in SQL, so if you search user descriptions for %ugly% , the database will return all records for ugly people.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • There is a lot of reasons not to use Edge but faster fixes and security updates is not one of them.
    • Can't reproduce. I installed Edge, went to neowin.net > accepted the cookie consent > used menu to go to forums, everything loads and I can browse around the forums. If you can't interact with the dialog on the forums for some reason, go to the main site and accept the cookie consent there? It is true that the site will not function properly until the cookie consent is accepted or rejected,. it's a legal requirement and I also know that certain VPN/ad blockers block it, which is a user related issue and not a neowin.net problem.   This is not our cookie consent dialog. Gotta love browser hijacking... /s Edit: this may be what Californians see, I will confirm with our consent provider.
    • Google Chrome 149.0.7827.115 (offline installer) by Razvan Serea The web browser is arguably the most important piece of software on your computer. You spend much of your time online inside a browser: when you search, chat, email, shop, bank, read the news, and watch videos online, you often do all this using a browser. Google Chrome is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier. Use one box for everything--type in the address bar and get suggestions for both search and Web pages. Thumbnails of your top sites let you access your favorite pages instantly with lightning speed from any new tab. Desktop shortcuts allow you to launch your favorite Web apps straight from your desktop. Chrome has many useful features built in, including automatic full-page translation and access to thousands of apps, extensions, and themes from the Chrome Web Store. Google Chrome is one of the best solutions for Internet browsing giving you high level of security, speed and great features. Important to know! The offline installer links do not include the automatic update feature. Download web installer: Google Chrome Web 32-bit | Google Chrome 64-bit | Freeware Download: Google Chrome Offline Installer 64-bit | Direct Link | 131.0 MB Download: Google Chrome Offline Installer 32-bit | Direct Link | 119.0 MB Download page: Google Chrome Portable Download: Chrome ARM64 | Direct Link View: Chrome Website | Release Notes Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Oh, it's happening on more than one dialog? This is the dialog that I'm unable to interact with.
    • WSCC - Windows System Control Center 10.0.3.8 by Razvan Serea Windows System Control Center is a free, portable program that allows you to install, update, execute and organize the utilities from various system utility suites. WSCC can install and update the supported utilities automatically. Alternatively, WSCC can use the http protocol to download and run the programs. WSCC is portable, installation is not required. Extract the content of the downloaded zip archive to any directory on your computer. Free for personal use. The setup packages and updates are downloaded directly from their author's website! This edition of WSCC supports the following utility suites: Windows Sysinternals Suite (including support for "Sysinternals Live" service) NirSoft Utilities Mitec and more... WSCC - Windows System Control Center 10.0.3.8 changelog: [NEW] update progress is now visible on the Windows taskbar [FIXED] fixed an issue with the Update dialog [FIXED] minor fixes Download: WSCC (64-bit) | 5.4 MB (Free for personal use) Download: WSCC (32-bit) | 6.3 MB View: WSCC Homepage | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • One Month Later
      Clizby earned a badge
      One Month Later
    • One Month Later
      Timaximus earned a badge
      One Month Later
    • Week One Done
      Timaximus earned a badge
      Week One Done
    • Rookie
      FBSPL went up a rank
      Rookie
    • First Post
      davidbazooked earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      492
    2. 2
      PsYcHoKiLLa
      170
    3. 3
      +Edouard
      164
    4. 4
      Steven P.
      85
    5. 5
      ATLien_0
      77
  • Tell a friend

    Love Neowin? Tell a friend!